-
Notifications
You must be signed in to change notification settings - Fork 112
/
glovar.py
64 lines (57 loc) · 2.45 KB
/
glovar.py
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
55
56
57
58
59
60
61
62
63
64
import time
import tzlocal
from pyrogram import Client
from loguru import logger
from botmodule import init_bot
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.interval import IntervalTrigger
from utils import cron_delete_message as cdm
from utils import cron_edit_message as cem
from utils import __version__
program_run_time = time.time()
bot_token = init_bot.bot_token
bot_config = init_bot.config
BUILD_TOKEN = init_bot.config.getBuildToken()
userbot_config = bot_config.config.get('userbot', {})
# 客户端
app = Client("my_bot",
api_id=init_bot.api_id,
api_hash=init_bot.api_hash,
bot_token=bot_token,
proxy=init_bot.BOT_PROXY,
app_version=__version__,
ipv6=False
)
app2 = None
if userbot_config.get('enable', False):
app2 = Client("my_user",
api_id=init_bot.api_id,
api_hash=init_bot.api_hash,
proxy=init_bot.BOT_PROXY,
app_version=__version__,
ipv6=False
)
scheduler = AsyncIOScheduler(timezone=str(tzlocal.get_localzone()))
scheduler.start()
scheduler.add_job(cdm, IntervalTrigger(seconds=10, timezone=str(tzlocal.get_localzone())), max_instances=10,
id='delete1', name="Delete the telegram message", args=(app,))
scheduler.add_job(cem, IntervalTrigger(seconds=5, timezone=str(tzlocal.get_localzone())), max_instances=10,
id='edit1', name="Edit the telegram message", args=(app,))
# ---------------------------- [ Print the bot ] ---------------------------- #
def bot_info(_app, _app2):
bot_me = _app.get_me()
logger.info('>> Bot Started')
logger.info(f'>> Bot ID: {bot_me.id} Username: @{bot_me.username}')
if _app2 is not None:
bot_me2 = _app2.get_me()
whitelist = userbot_config.get('whitelist', [])
userbot_config['id'] = bot_me2.id
if bot_me.id not in whitelist:
whitelist.append(bot_me.id)
userbot_config['whitelist'] = whitelist
bot_config.yaml['userbot'] = userbot_config
bot_config.reload()
logger.info('>> UserBot enable')
logger.info(f'>> UserBot ID: {bot_me2.id} Username: @{bot_me2.username}')
print("""# ---------------------------- [ Start the bot ] ---------------------------- # """)
print("""# ---------------------------- [ Check Bot Successful ] ---------------------------- # """)