-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.py
41 lines (35 loc) · 1.46 KB
/
user.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
import responses
class User:
def __init__(self, update, users_cf):
self.first_name = update.message.chat.first_name
self.last_name = update.message.chat.last_name
self.user_id = update.message.from_user.id
self.sticker_max = users_cf['sticker_limit']
self.sticker_count = 0
self.quiz_encounter = False
self.bonus_sticker_encounter = False
self.end_message_encounter = False
self.sticker_history = []
def __eq__(self, other):
if self.user_id == other.user_id:
return True
return False
def get_limit_response(self):
if self.sticker_count >= self.sticker_max:
if not self.end_message_encounter:
self.end_message_encounter = True
return responses.END_MESSAGE
else:
return responses.OUT_OF_STICKERS
else:
return responses.STICKER_COUNT.format(count=str(self.sticker_max - self.sticker_count))
def log_message(self, message_id):
self.sticker_history.append(message_id)
# Check this user has the given message ID In their sticker history
# This is for if the user has their chat hidden for forwarded messages
# This is the message ID in the superuser's chat that is forwarded by the sticker monitor
def check_log(self, message_id):
for i in self.sticker_history:
if message_id == i:
return True
return False