Skip to content

Commit fb2f151

Browse files
committed
Merge pull request #73 from d-Rickyy-b/dev
FIX: NoneType bug in game_commands
2 parents 4b91ef8 + 8920c7f commit fb2f151

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22
sudo: require
33
python:
44
- "3.4"
5+
- "3.6"
56
# command to install dependencies
67
install:
78
- pip install python-telegram-bot --upgrade

game/blackJackGame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def dealers_turn(self):
150150
i += 1
151151

152152
output_text += "\n\n{} {}".format(translate("cardvalueDealer", self.lang_id), self.dealer.cardvalue)
153-
self.send_message(self.chat_id, output_text, parse_mode="Markdown", reply_markup=self.keyboard_running)
153+
self.send_message(self.chat_id, output_text, parse_mode="Markdown", reply_markup=ReplyKeyboardRemove())
154154
self.evaluation()
155155

156156
def start_game(self, message_id: int = None) -> None:

main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
# Internal methods
4949
# -----------------
5050
def change_language(bot, update, lang_id):
51+
logger.info("Language changed to '{}' for user {}".format(lang_id, update.effective_user.id))
5152
bot.editMessageText(chat_id=update.callback_query.message.chat_id, text=translate("langChanged", lang_id),
5253
message_id=update.callback_query.message.message_id, reply_markup=None)
5354
db = DBwrapper.get_instance()
@@ -94,8 +95,11 @@ def send_mp_message(chat_id, text, message_id=None, parse_mode=None, reply_marku
9495

9596

9697
def game_commands(bot, update):
97-
text = update.message.text
98-
chat_id = update.message.chat_id
98+
if update.message is None:
99+
logger.warning("game_commands error happened again! Update: {}".format(update))
100+
101+
text = update.effective_message.text
102+
chat_id = update.effective_message.chat_id
99103
user = update.effective_user
100104
user_id = user.id
101105
first_name = user.first_name
@@ -467,5 +471,5 @@ def restart(bot, update):
467471
dispatcher.add_error_handler(error)
468472

469473
updater.start_polling()
470-
logger.info("Bot started")
474+
logger.info("Bot started as @{}".format(updater.bot.username))
471475
updater.idle()

0 commit comments

Comments
 (0)