-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (47 loc) · 1.73 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
import telebot
from telebot import types
import requests
import logging
from handlers import handle_command_options
from logic import handle_get_current_trains
from constants import BOT_API_KEY, AVAILABLE_STATIONS
logging.basicConfig(level=logging.INFO, format="%(message)s")
logger = logging.getLogger(__name__)
bot = telebot.TeleBot(BOT_API_KEY)
@bot.message_handler(commands=["help"])
def get_current_trains(message):
logger.info("Got Help requesst")
answer = "Hey there, there's no help coming your way" # TODO: add help
bot.reply_to(message, answer)
# --- config commands ---
@bot.message_handler(commands=["setHome"])
def get_current_trains(message):
logger.info("Got set home station request")
markup = types.InlineKeyboardMarkup()
for station in AVAILABLE_STATIONS:
item = types.InlineKeyboardButton(
text=station["stationName"], callback_data=station["stationId"]
)
markup.add(item)
bot.send_message(message.chat.id, "Choose an option:", reply_markup=markup)
# return
@bot.message_handler(commands=["setWork"])
def get_current_trains(message):
logger.info("Got work station request")
answer = handle_command_options(message, mode="toWork")
bot.reply_to(message, answer)
return answer
# --- information commands ---
@bot.message_handler(commands=["toWork"])
def get_current_trains(message):
logger.info("Got toWork request")
answer = handle_command_options(message, mode="toWork")
bot.reply_to(message, answer)
return answer
@bot.message_handler(commands=["toHome"])
def get_current_trains(message):
logger.info("Got toHome request")
answer = handle_get_current_trains()
bot.reply_to(message, answer)
bot.infinity_polling()