imaginaryfriend/src/domain/status.py

23 lines
631 B
Python
Raw Normal View History

2016-11-12 13:37:14 +01:00
from src.utils import deep_get_attr
2016-11-12 16:36:23 +01:00
from src.config import config
2016-11-12 13:37:14 +01:00
class Status:
2016-11-12 14:56:42 +01:00
def __init__(self, chat, message):
2016-11-12 13:37:14 +01:00
self.chat = chat
self.message = message
def is_bot_kicked(self):
"""Returns True if the bot was kicked from group.
"""
user_name = deep_get_attr(self.message, 'left_chat_member.username')
2016-11-12 14:56:42 +01:00
return user_name == config['bot']['name']
2016-11-12 13:37:14 +01:00
def is_bot_added(self):
"""Returns True if the bot was added to group.
"""
user_name = deep_get_attr(self.message, 'new_chat_member.username')
2016-11-12 14:56:42 +01:00
return user_name == config['bot']['name']