Merge branch 'qubitnerd-qubitnerd_remind_feature'
This commit is contained in:
commit
8fe190133f
5 changed files with 36 additions and 1 deletions
|
@ -7,5 +7,6 @@
|
||||||
The following wonderful people contributed directly or indirectly to this project:
|
The following wonderful people contributed directly or indirectly to this project:
|
||||||
|
|
||||||
- [imlonghao](https://github.com/imlonghao)
|
- [imlonghao](https://github.com/imlonghao)
|
||||||
|
- [qubitnerd](https://github.com/qubitnerd)
|
||||||
|
|
||||||
Please add yourself here alphabetically when you submit your first pull request.
|
Please add yourself here alphabetically when you submit your first pull request.
|
27
bot.py
27
bot.py
|
@ -52,6 +52,22 @@ logging.basicConfig(
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
|
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=_("Send this command in a group to be notified "
|
||||||
|
"when a new game is started there."))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
gm.remind_dict[chat_id].append(update.message.from_user.id)
|
||||||
|
except KeyError:
|
||||||
|
gm.remind_dict[chat_id] = [update.message.from_user.id]
|
||||||
|
|
||||||
|
|
||||||
@user_locale
|
@user_locale
|
||||||
def new_game(bot, update):
|
def new_game(bot, update):
|
||||||
"""Handler for the /new command"""
|
"""Handler for the /new command"""
|
||||||
|
@ -61,6 +77,16 @@ def new_game(bot, update):
|
||||||
help(bot, update)
|
help(bot, update)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
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 = gm.new_game(update.message.chat)
|
||||||
game.owner = update.message.from_user
|
game.owner = update.message.from_user
|
||||||
send_async(bot, chat_id,
|
send_async(bot, chat_id,
|
||||||
|
@ -711,6 +737,7 @@ dispatcher.add_handler(CommandHandler('enable_translations',
|
||||||
dispatcher.add_handler(CommandHandler('disable_translations',
|
dispatcher.add_handler(CommandHandler('disable_translations',
|
||||||
disable_translations))
|
disable_translations))
|
||||||
dispatcher.add_handler(CommandHandler('skip', skip_player))
|
dispatcher.add_handler(CommandHandler('skip', skip_player))
|
||||||
|
dispatcher.add_handler(CommandHandler('next_game',next_game))
|
||||||
simple_commands.register()
|
simple_commands.register()
|
||||||
settings.register()
|
settings.register()
|
||||||
dispatcher.add_handler(MessageHandler([Filters.status_update], status_update))
|
dispatcher.add_handler(MessageHandler([Filters.status_update], status_update))
|
||||||
|
|
|
@ -33,6 +33,8 @@ class GameManager(object):
|
||||||
self.chatid_games = dict()
|
self.chatid_games = dict()
|
||||||
self.userid_players = dict()
|
self.userid_players = dict()
|
||||||
self.userid_current = dict()
|
self.userid_current = dict()
|
||||||
|
self.remind_dict = dict()
|
||||||
|
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def new_game(self, chat):
|
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"
|
msgid "Created a new game! Join the game with /join and start the game with /start"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: bot.py
|
||||||
|
msgid "Send this command in a group to be notified when a new game is started there."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:152
|
#: bot.py:152
|
||||||
msgid "The lobby is closed"
|
msgid "The lobby is closed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -40,7 +40,8 @@ help_text = ("Follow these steps:\n\n"
|
||||||
"the selected action.\n"
|
"the selected action.\n"
|
||||||
"Players can join the game at any time. To leave a game, "
|
"Players can join the game at any time. To leave a game, "
|
||||||
"use /leave. If a player takes more than 90 seconds to play, "
|
"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"
|
"<b>Language</b> and other settings: /settings\n"
|
||||||
"Other commands (only game creator):\n"
|
"Other commands (only game creator):\n"
|
||||||
"/close - Close lobby\n"
|
"/close - Close lobby\n"
|
||||||
|
|
Loading…
Reference in a new issue