-
Notifications
You must be signed in to change notification settings - Fork 8
/
run.py
31 lines (24 loc) · 865 Bytes
/
run.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
import os
import sys
import asyncio
from dotenv import load_dotenv
from main import AiogramLlmBot
default_config_file_path = "configs/app_config.json"
def run_server(token, config_file_path=""):
if not config_file_path:
config_file_path = default_config_file_path
if not token:
load_dotenv()
token = os.environ.get("BOT_TOKEN", "")
# create TelegramBotWrapper instance
# by default, read parameters in telegram_config.cfg
tg_server = AiogramLlmBot(config_file_path=config_file_path)
asyncio.run(tg_server.run_telegram_bot(token))
# Press the green button in the gutter to run the script.
if __name__ == "__main__":
if len(sys.argv) > 2:
run_server(sys.argv[1], sys.argv[2])
elif len(sys.argv) > 1:
run_server(sys.argv[1])
else:
run_server("")