-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
42 lines (32 loc) · 1.52 KB
/
main.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
from apscheduler.schedulers.background import BackgroundScheduler
import subscriptions
from config import bot, logger
from subscriptions import job
@bot.message_handler(commands=["start", "help"])
def info(msg):
bot.reply_to(msg, "Бот для ведения учёта статистики брокерского портфеля Тинькофф.\n"
"Доступные функции:\n"
"/subscribe - подписка на обновления портфеля\n"
"/unsubscribe - отписка от обновлений портфеля\n")
@bot.message_handler(commands=["subscribe"])
def subscribe(msg):
bot.reply_to(msg, "Введите информацию о новой подписке в формате: "
"<Tinkoff API token> "
"<Broker account ID> "
)
bot.register_next_step_handler(msg, subscriptions.subscribe)
@bot.message_handler(commands=["unsubscribe"])
def unsubscribe(msg):
bot.reply_to(msg, "Введите информацию об отписке в формате: "
"<Broker account ID> "
)
bot.register_next_step_handler(msg, subscriptions.unsubscribe)
if __name__ == "__main__":
scheduler = BackgroundScheduler()
scheduler.add_job(job, "interval", days=1)
scheduler.start()
try:
bot.infinity_polling()
except (KeyboardInterrupt, SystemExit) as e:
scheduler.shutdown()
logger.error(e)