From 0e17748e3aa1b3762afdb05546f168fda282897b Mon Sep 17 00:00:00 2001 From: Jerry Date: Mon, 13 Dec 2021 20:49:32 +0800 Subject: [PATCH] what the f**k why would you add lock to the user and chat object, are you crazy? --- requirements.txt | 3 +++ tgmsbot.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..33c77fc --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +numpy==1.21.4 +peewee==3.14.8 +python-telegram-bot==13.9 diff --git a/tgmsbot.py b/tgmsbot.py index 757c742..33b5a98 100644 --- a/tgmsbot.py +++ b/tgmsbot.py @@ -90,8 +90,8 @@ def display_username(user, atuser=True, shorten=False, markdown=True): class Game: def __init__(self, board, group, creator, lives=1): self.board = board - self.group = group - self.creator = creator + self.group = self.nobot(group) + self.creator = self.nobot(creator) self.msgid = None self.__actions = dict() self.last_player = None @@ -106,6 +106,10 @@ class Game: self.lives = lives self.ttl_lives = lives self.lock = Lock() + @staticmethod + def nobot(input): + setattr(input, "bot", None) + return input def __getstate__(self): """ https://docs.python.org/3/library/pickle.html#handling-stateful-objects """ state = self.__dict__.copy() @@ -116,6 +120,7 @@ class Game: self.lock = Lock() def save_action(self, user, spot): '''spot is supposed to be a tuple''' + user = self.nobot(user) self.last_player = user self.__actions.setdefault(user, list()).append(spot) def actions_sum(self):