Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion telegram/ext/messagehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def text(message):

@staticmethod
def command(message):
return message.text and message.text.startswith('/')
if len(message.entities) == 1:
return bool(message.entities[0].type == 'bot_command')
else:
return False

@staticmethod
def audio(message):
Expand Down Expand Up @@ -73,6 +76,76 @@ def location(message):
def venue(message):
return bool(message.venue)

@staticmethod
def mention(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'mention')
else:
return False

@staticmethod
def hashtag(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'hashtag')
else:
return False

@staticmethod
def url(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'url')
else:
return False

@staticmethod
def email(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'email')
else:
return False

@staticmethod
def bold(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'bold')
else:
return False

@staticmethod
def italic(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'italic')
else:
return False

@staticmethod
def code(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'code')
else:
return False

@staticmethod
def pre(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'pre')
else:
return False

@staticmethod
def text_link(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'text_link')
else:
return False

@staticmethod
def text_mention(message):
if len(message.entities) == 1:
return bool(message.entities[0].type == 'text_mention')
else:
return False

@staticmethod
def status_update(message):
return bool(message.new_chat_member or message.left_chat_member or message.new_chat_title
Expand All @@ -82,6 +155,7 @@ def status_update(message):
or message.migrate_from_chat_id or message.pinned_message)



class MessageHandler(Handler):
"""
Handler class to handle telegram messages. Messages are Telegram Updates
Expand Down