what the f**k why would you add lock to the user and chat object, are you crazy?
This commit is contained in:
parent
99f7055178
commit
0e17748e3a
2 changed files with 10 additions and 2 deletions
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
numpy==1.21.4
|
||||||
|
peewee==3.14.8
|
||||||
|
python-telegram-bot==13.9
|
|
@ -90,8 +90,8 @@ def display_username(user, atuser=True, shorten=False, markdown=True):
|
||||||
class Game:
|
class Game:
|
||||||
def __init__(self, board, group, creator, lives=1):
|
def __init__(self, board, group, creator, lives=1):
|
||||||
self.board = board
|
self.board = board
|
||||||
self.group = group
|
self.group = self.nobot(group)
|
||||||
self.creator = creator
|
self.creator = self.nobot(creator)
|
||||||
self.msgid = None
|
self.msgid = None
|
||||||
self.__actions = dict()
|
self.__actions = dict()
|
||||||
self.last_player = None
|
self.last_player = None
|
||||||
|
@ -106,6 +106,10 @@ class Game:
|
||||||
self.lives = lives
|
self.lives = lives
|
||||||
self.ttl_lives = lives
|
self.ttl_lives = lives
|
||||||
self.lock = Lock()
|
self.lock = Lock()
|
||||||
|
@staticmethod
|
||||||
|
def nobot(input):
|
||||||
|
setattr(input, "bot", None)
|
||||||
|
return input
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
""" https://docs.python.org/3/library/pickle.html#handling-stateful-objects """
|
""" https://docs.python.org/3/library/pickle.html#handling-stateful-objects """
|
||||||
state = self.__dict__.copy()
|
state = self.__dict__.copy()
|
||||||
|
@ -116,6 +120,7 @@ class Game:
|
||||||
self.lock = Lock()
|
self.lock = Lock()
|
||||||
def save_action(self, user, spot):
|
def save_action(self, user, spot):
|
||||||
'''spot is supposed to be a tuple'''
|
'''spot is supposed to be a tuple'''
|
||||||
|
user = self.nobot(user)
|
||||||
self.last_player = user
|
self.last_player = user
|
||||||
self.__actions.setdefault(user, list()).append(spot)
|
self.__actions.setdefault(user, list()).append(spot)
|
||||||
def actions_sum(self):
|
def actions_sum(self):
|
||||||
|
|
Loading…
Reference in a new issue