Fixed cross-import issue

This commit is contained in:
2022-09-15 12:55:33 +02:00
parent 02d945aef5
commit e9d083c156
3 changed files with 15 additions and 18 deletions

16
bot.py
View File

@@ -13,14 +13,14 @@ if configGet("bot_token") != "12345678:asdfghjklzxcvbnm":
pid = getpid()
app = Client("auto_zoom_public_bot", api_id=configGet("api_id"), api_hash=configGet("api_hash"), bot_token=configGet("bot_token"))
else:
logWrite("Could not start the bot. Please, configure token in config.json")
logWrite("Could not start the bot. Please, configure token in config.json", logs_folder=configGet("logs"))
exit()
@app.on_message(~ filters.scheduled & filters.command(["link", "start"], prefixes="/"))
async def start(app, msg):
logWrite(f'Got command start/link from {msg.from_user.id}')
logWrite(f'Got command start/link from {msg.from_user.id}', logs_folder=configGet("logs"))
await app.send_chat_action(chat_id=msg.chat.id, action=ChatAction.TYPING)
@@ -28,7 +28,7 @@ async def start(app, msg):
data = configGet("data")
if f"{msg.from_user.id}.json" not in listdir(f"{data}{sep}users{sep}"):
logWrite(f'Creating blank data file for {msg.from_user.id}')
logWrite(f'Creating blank data file for {msg.from_user.id}', logs_folder=configGet("logs"))
jsonSave( f"{data}{sep}users{sep}{msg.from_user.id}.json", {"api_key": None, "linked": False, "context": {"action": None, "data": None}} )
if not userGet(msg.from_user.id, "linked"):
@@ -40,7 +40,7 @@ async def start(app, msg):
@app.on_message(~ filters.scheduled & filters.command(["unlink"], prefixes="/"))
async def unlink(app, msg):
logWrite(f'Got command ulink from {msg.from_user.id}')
logWrite(f'Got command ulink from {msg.from_user.id}', logs_folder=configGet("logs"))
await app.send_chat_action(chat_id=msg.chat.id, action=ChatAction.TYPING)
@@ -98,9 +98,9 @@ async def any_message_handler(app, msg):
keys_storage = jsonLoad(f"{data}{sep}keys_storage.json")
keys_storage[msg.text] = msg.from_user.id
jsonSave(f"{data}{sep}keys_storage.json", keys_storage)
logWrite(f"Added apikey {msg.text} for user {msg.from_user.id}")
logWrite(f"Added apikey {msg.text} for user {msg.from_user.id}", logs_folder=configGet("logs"))
else:
logWrite(f"User {msg.from_user.id} tried to pair with invalid apikey {msg.text}")
logWrite(f"User {msg.from_user.id} tried to pair with invalid apikey {msg.text}", logs_folder=configGet("logs"))
await msg.reply_text(locale("key_wrong", "msg", locale=user_locale))
userClear(msg.from_user.id, "context")
@@ -109,7 +109,7 @@ async def any_message_handler(app, msg):
if __name__ == "__main__":
logWrite(f'Starting with PID {str(pid)}')
logWrite(f'Starting with PID {str(pid)}', logs_folder=configGet("logs"))
app.start()
app.send_message(configGet("admin"), f"Starting bot with pid `{pid}`")
@@ -139,6 +139,6 @@ if __name__ == "__main__":
idle()
app.send_message(configGet("admin"), f"Shutting down bot with pid `{pid}`")
logWrite(f'Shutting down with PID {pid}')
logWrite(f'Shutting down with PID {pid}', logs_folder=configGet("logs"))
killProc(pid)