-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
80 lines (62 loc) · 2.08 KB
/
bot.py
File metadata and controls
80 lines (62 loc) · 2.08 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import telebot
import config
from utils import tools
from utils.decorators import check_new_day
from utils.scheduler import Scheduler
from utils.tools import DeletionError
from utils.tools import MembersError
from utils.tools import TimeFormatError
from utils.tools import TimingError
bot = telebot.TeleBot(config.TOKEN)
scheduler = Scheduler()
@bot.message_handler(commands=['schedule'])
@check_new_day
def show_schedule(message):
schedule = scheduler.print_schedule()
# TODO format output
bot.send_message(message.chat.id, str(schedule))
@bot.message_handler(commands=['add'])
@check_new_day
def add_to_game(message):
game_time = tools.get_command_params(message)
user = tools.get_username(message)
try:
msg = scheduler.add_to_schedule(game_time, user)
bot.send_message(message.chat.id, msg)
except (TimeFormatError, MembersError, TimingError) as e:
bot.send_message(message.chat.id, e)
@bot.message_handler(commands=['del'])
@check_new_day
def delete_from_game(message):
game_time = tools.get_command_params(message)
user = tools.get_username(message)
try:
msg = scheduler.delete_from(game_time, user)
bot.send_message(message.chat.id, msg)
except (DeletionError, TimeFormatError) as e:
bot.send_message(message.chat.id, e)
@bot.message_handler(commands=['me', 'myschedule'])
@check_new_day
def show_my_schedule(message):
user = tools.get_username(message)
schedule = scheduler.my_games(user)
bot.send_message(message.chat.id, schedule)
@bot.message_handler(commands=['team'])
@check_new_day
def show_team(message):
prm = tools.get_command_params(message)
try:
msg = scheduler.print_team(prm)
bot.send_message(message.chat.id, msg)
except (TimeFormatError, MembersError) as e:
bot.send_message(message.chat.id, e)
@bot.message_handler(commands=['moveteam'])
@check_new_day
def move_teame(message):
# TODO implement functionality
pass
@bot.message_handler(commands=['moveme'])
@check_new_day
def move_me(message):
# TODO implement functionality
pass