-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_methods.py
More file actions
55 lines (41 loc) · 1.93 KB
/
update_methods.py
File metadata and controls
55 lines (41 loc) · 1.93 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
import DB
from DB_functions import load_players
from bet_helpers import upsert_bet, extract_from_wa_messages
from players_data_helpers import get_current_bets
from schedule_extraction_helpers import get_next_matches
from scoreboard_helpers import scoreboard_table, update_scoreboard
def scoreboard(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text=scoreboard_table())
def get_matches(update, context):
if len(context.args) == 0:
days = 1
else:
try:
days = int(context.args[0])
except Exception:
days = 1
context.bot.send_message(chat_id=update.effective_chat.id, text=get_next_matches(days=days))
def bet(update, context):
try:
alias = upsert_bet(context.args)
players = load_players()
context.bot.send_message(chat_id=update.effective_chat.id,
text="Upserted bet for {}: {}".format(players[alias].get_name(),
', '.join(players[alias].get_current_bet())))
except ValueError as err:
context.bot.send_message(chat_id=update.effective_chat.id, text=repr(err))
def wa_bets(update, context):
player_bets = extract_from_wa_messages(context.args)
for player in player_bets:
upsert_bet([player] + list(player_bets[player]))
context.bot.send_message(chat_id=update.effective_chat.id, text=get_current_bets())
def next_round(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text=scoreboard_table() + '\n' + get_next_matches())
def match_winners(update, context):
try:
update_scoreboard(context.args)
next_round(update, context)
except Exception as err:
context.bot.send_message(chat_id=update.effective_chat.id, text=repr(err))
def current_bets(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text=get_current_bets())