-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_executer.py
80 lines (60 loc) · 2.9 KB
/
command_executer.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from db_wrapper import DatabaseWrapper
from db_updater import DatabaseUpdater
from messages import *
import random
from datetime import datetime, timedelta
class CommandExecuter:
def __init__(self, channel, power_user: bool):
self._channel_name = channel.name
self._db = DatabaseWrapper(self._channel_name)
self._db_updater = DatabaseUpdater(self._db)
self._power_user = power_user
self.account_name = self._db.get_active_account()
def versus(self, opponent):
if not opponent.isalnum() or opponent == "versus":
return ""
self._db_updater.update_database(self._power_user)
[wins, loses, points] = self._db.get_wins_loses_vs_opponent(opponent)
return versus_msg(self.account_name, wins, loses, points, opponent)
def dzisiaj(self):
self._db_updater.update_database(self._power_user)
todays_date = datetime.now().date()
[wins, loses, point_sum] = self._db.get_wins_loses_points_for_date(todays_date)
return today_msg(self.account_name, wins, loses, point_sum)
def wczoraj(self):
self._db_updater.update_database(self._power_user)
yesterday_date = datetime.now().date() - timedelta(days = 1)
[wins, loses, point_sum] = self._db.get_wins_loses_points_for_date(yesterday_date)
return yesterday_msg(self.account_name, wins, loses, point_sum)
def dzisiaj_detale(self):
self._db_updater.update_database(self._power_user)
todays_date = datetime.now().date()
[results, points] = self._db.get_detailed_date(todays_date)
msg = ""
for enemy_name, [wins, loses] in results.items(): #todo add points
msg += detailed_match_msg(enemy_name, wins, loses)
if msg != "":
msg += f"[{points:+}p.] " + emote_points(points)
return msg
def wczoraj_detale(self):
self._db_updater.update_database(self._power_user)
yesterday_date = datetime.now().date() - timedelta(days = 1)
[results, points] = self._db.get_detailed_date(yesterday_date)
msg = ""
for enemy_name, [wins, loses] in results.items(): #todo add poitns
msg += detailed_match_msg(enemy_name, wins, loses)
if msg != "":
msg += f"[{points:+}p.] " + emote_points(points)
return msg
def konto(self, new_active_account):
self._db_updater.update_database(self._power_user)
[points, rating] = self._db.get_points_and_rank()
return update_account_msg(new_active_account, points, rating)
def punkty(self):
self._db_updater.update_database(self._power_user)
[points, _] = self._db.get_points_and_rank()
return points_msg(self.account_name, points)
def last(self):
self._db_updater.update_database(self._power_user)
m = self._db.get_last_match()
return last_match_msg(m)