Skip to content

Commit

Permalink
Test group_message
Browse files Browse the repository at this point in the history
  • Loading branch information
Sardor Muminov committed Jul 26, 2017
1 parent 7cf6ddf commit af491f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 0 additions & 7 deletions aiotg/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,19 +525,14 @@ async def _track(self, message, name):
await response.release()

def _process_message(self, message):
logger.debug("_process_message %s", message)
chat = Chat.from_message(self, message)
logger.debug("chat is group? %s", chat.is_group())

for mt in MESSAGE_TYPES:
logger.debug("mt %s", mt)
if mt in message:
logger.debug("mt in message %s", message)
self.track(message, mt)
return self._handlers[mt](chat, message[mt])

if "text" not in message:
logger.debug("no text in message %s", message)
return

for patterns, handler in self._commands:
Expand Down Expand Up @@ -593,9 +588,7 @@ def _process_update(self, update):

# Determine update type starting with message updates
for ut in MESSAGE_UPDATES:
logger.debug("ut %s", ut)
if ut in update:
logger.debug("ut in update %s", update)
coro = self._process_message(update[ut])
break
else:
Expand Down
13 changes: 11 additions & 2 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,14 @@ async def left_chat_member_event(chat, member):


@bot.group_message
async def get_group_messages(chat, message):
logger.info('Got message from group %s', message)
async def group_message_event(chat, message):
sender = message.get('from')
sender_id = sender.get('id') # noqa
sender_name = sender.get('first_name')
chat = message.get('chat')
group_id = chat.get('id')
message_date = message.get('date')
message_text = message.get('text')
logger.info('Got message from group %s at %s', (group_id, message_date))
logger.info('Sender %s', (sender_name))
logger.info('Text ->', message_text)

0 comments on commit af491f2

Please sign in to comment.