/
bot.py
37 lines (28 loc) · 1.04 KB
/
bot.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
import os
from telebot import TeleBot, apihelper
from helpers import parse, format_dict
from middleware import correct_message
from package import PackageData, WrongIdError
# proxies = {
# 'http': 'socks5://72.210.252.134:46164',
# 'https': 'socks5://72.210.252.134:46164'
# }
#
# apihelper.proxy = proxies
bot = TeleBot(os.environ['TOKEN'])
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, "Пришлите индентификатор посылки")
@bot.message_handler(content_types=['text'])
def track_message(message):
if correct_message(message.text):
try:
history = PackageData(message.text).history_record
data = parse(history)
bot.send_message(message.chat.id, format_dict(data))
except WrongIdError:
bot.send_message(message.chat.id, "ID не найден")
else:
bot.send_message(message.chat.id, 'Неверный фортмат ID')
if __name__ == '__main__':
bot.polling(none_stop=True)