imaginaryfriend/src/domain/status.py

23 lines
697 B
Python
Raw Normal View History

2016-11-12 23:55:48 +01:00
from .abstract_entity import AbstractEntity
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
2016-11-12 23:55:48 +01:00
class Status(AbstractEntity):
2016-11-12 14:56:42 +01:00
def __init__(self, chat, message):
2016-11-13 12:55:23 +01:00
super(Status, self).__init__(chat=chat, message=message)
2016-11-12 13:37:14 +01:00
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']