formatting, exception handling, documentation
This commit is contained in:
parent
e28bcc58ad
commit
b136bdf997
4 changed files with 27 additions and 10 deletions
28
bot.py
28
bot.py
|
@ -51,18 +51,21 @@ logging.basicConfig(
|
|||
level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
remind_dict = {}
|
||||
|
||||
@user_locale
|
||||
def next_game(bot, update):
|
||||
"""handler for /next_game command , pm people for next game"""
|
||||
def notify_me(bot, update):
|
||||
"""Handler for /notify_me command, pm people for next game"""
|
||||
chat_id = update.message.chat_id
|
||||
if update.message.chat.type == 'private':
|
||||
send_async(bot, chat_id,text="call this in a group to be reminded ")
|
||||
send_async(bot,
|
||||
chat_id,
|
||||
text=_("Send this command in a group to be notified "
|
||||
"when a new game is started there."))
|
||||
else:
|
||||
try:
|
||||
remind_dict[chat_id].append(update.message.from_user.id)
|
||||
gm.remind_dict[chat_id].append(update.message.from_user.id)
|
||||
except KeyError:
|
||||
remind_dict[chat_id] = [update.message.from_user.id]
|
||||
gm.remind_dict[chat_id] = [update.message.from_user.id]
|
||||
|
||||
|
||||
@user_locale
|
||||
|
@ -74,9 +77,16 @@ def new_game(bot, update):
|
|||
help(bot, update)
|
||||
|
||||
else:
|
||||
for user in remind_dict[update.message.chat_id]:
|
||||
send_async(bot , user , text = "A new game has been started in " + update.message.chat.title)
|
||||
del remind_dict[update.message.chat_id]
|
||||
|
||||
if update.message.chat_id in gm.remind_dict:
|
||||
for user in gm.remind_dict[update.message.chat_id]:
|
||||
send_async(bot,
|
||||
user,
|
||||
text="A new game has been started in " +
|
||||
update.message.chat.title)
|
||||
|
||||
del gm.remind_dict[update.message.chat_id]
|
||||
|
||||
game = gm.new_game(update.message.chat)
|
||||
game.owner = update.message.from_user
|
||||
send_async(bot, chat_id,
|
||||
|
|
|
@ -33,6 +33,8 @@ class GameManager(object):
|
|||
self.chatid_games = dict()
|
||||
self.userid_players = dict()
|
||||
self.userid_current = dict()
|
||||
self.remind_dict = dict()
|
||||
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
def new_game(self, chat):
|
||||
|
|
|
@ -75,6 +75,10 @@ msgstr ""
|
|||
msgid "Created a new game! Join the game with /join and start the game with /start"
|
||||
msgstr ""
|
||||
|
||||
#: bot.py
|
||||
msgid "Send this command in a group to be notified when a new game is started there."
|
||||
msgstr ""
|
||||
|
||||
#: bot.py:152
|
||||
msgid "The lobby is closed"
|
||||
msgstr ""
|
||||
|
|
|
@ -40,7 +40,8 @@ help_text = ("Follow these steps:\n\n"
|
|||
"the selected action.\n"
|
||||
"Players can join the game at any time. To leave a game, "
|
||||
"use /leave. If a player takes more than 90 seconds to play, "
|
||||
"you can use /skip to skip that player.\n\n"
|
||||
"you can use /skip to skip that player. Use /notify_me to "
|
||||
"receive a private message when a new game is started.\n\n"
|
||||
"<b>Language</b> and other settings: /settings\n"
|
||||
"Other commands (only game creator):\n"
|
||||
"/close - Close lobby\n"
|
||||
|
|
Loading…
Reference in a new issue