forked from TheVaders/MusicBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
54 lines (46 loc) · 1.25 KB
/
bot.py
File metadata and controls
54 lines (46 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from pyrogram import Client
from config import API_ID, API_HASH, BOT_TOKEN
app = Client(
"my_account",
API_ID,
API_HASH,
bot_token=BOT_TOKEN,
plugins=dict(root="handlers")
)
if __name__ == "__main__":
import os
import sys
from threading import Thread
from pyrogram import idle, filters
from pyrogram.handlers import MessageHandler
from config import SUDO_USERS, BOT_NAME
def stop_and_restart():
app.stop()
os.system("git pull")
os.execl(sys.executable, sys.executable, *sys.argv)
@app.on_message(
filters.command(["restart", "update"])
& filters.group
& ~ filters.edited
)
@errors
@admins_only
def restart(client, message):
message.reply_text(f"**{BOT_NAME} :** Restarting and pulling latest codes...")
Thread(
target=stop_and_restart
).start()
@app.on_message(
filters.command(["restart", "update"])
& filters.private
& ~ filters.edited
)
@errors
@admins_only
def restart(client, message):
message.reply_text(f"**{BOT_NAME} :** Restarting and pulling latest codes...")
Thread(
target=stop_and_restart
).start()
app.start()
idle()