def call(self, chat, author, arguments): player = db.find_player_by_telegram_id(author) if player is None: telegram.send(chat, 'Introduce yourself by providing your psn id: /register <psn-id>') return event_list = db.find_events() if arguments is None: event_list = filter(lambda e: e.date.date() == datetime.today().date(), event_list) elif arguments == 'my': event_list = filter(lambda e: player.psn_id in e.participants, event_list) elif arguments == 'all': pass elif arguments is not None: if arguments.isdigit(): event_list = filter(lambda e: int(arguments) == int(e.key.id()), event_list) else: event_type = db.find_type_by_code(arguments) if event_type is None: telegram.send(chat, 'Event type ' + arguments + ' not found') return event_list = filter(lambda e: e.type == event_type.key, event_list) if len(event_list) == 0: telegram.send(chat, 'No events') return for e in event_list: telegram.send(chat, pretty_event(e))
def call(self, chat, author, arguments): player = db.find_player_by_telegram_id(author) if player is None: telegram.send(chat, "Introduce yourself by providing your psn id: /r register <psn-id>") return event_list = db.find_events() if len(event_list) == 0: telegram.send(author, "No events") return if arguments is not None: event_list = filter(lambda e: player.psn_id in e.participants, event_list) for e in event_list: telegram.send(chat, pretty_event(e))
def get_template_values(player): types_list = db.find_types() types = dict(map(lambda event_type: (event_type.key.id(), event_type), types_list)) grouped_types = groupby(types_list, db.EventType.pretty_group) grouped_events = groupby(db.find_events(), pretty_date) template_values = { 'player': player, 'types': types, 'grouped_types': grouped_types, 'grouped_events': grouped_events } return template_values
def get_template_values(player): types_list = db.find_types() types = dict( map(lambda event_type: (event_type.key.id(), event_type), types_list)) grouped_types = groupby(types_list, db.EventType.pretty_group) grouped_events = groupby(db.find_events(), pretty_date) template_values = { 'player': player, 'types': types, 'grouped_types': grouped_types, 'grouped_events': grouped_events } return template_values
def call(self, chat, author, arguments): player = db.find_player_by_telegram_id(author) if player is None: telegram.send( chat, "Introduce yourself by providing your psn id: /r register <psn-id>" ) return event_list = db.find_events() if len(event_list) == 0: telegram.send(author, "No events") return if arguments is not None: event_list = filter(lambda e: player.psn_id in e.participants, event_list) for e in event_list: telegram.send(chat, pretty_event(e))