def today_default_command(message): chat_id = message['message']['chat']['id'] if not app.db.schedules.users_groups.count_documents({'chat_id': chat_id}): return 'Set your study group (//setgroup)' return get_schedule( app.db.schedules.date.find_one({'name': 'curr_day'})['curr_day'], app.db.schedules.date.find_one({'name': 'curr_week'})['curr_week'], app.db.schedules.users_groups.find_one({'chat_id': chat_id})['group'])
def tomorrow_command(message): group_number = message['message']['text'].split()[-1] day = (app.db.schedules.date.find_one({'name': 'curr_day'})['curr_day'] + 1) % 7 week = ( app.db.schedules.date.find_one({'name': 'curr_week'})['curr_week'] + (day == 0)) % 4 + (day == 0) return get_schedule(day, week, group_number)
def rtoday_schedule(request): user_id = request['message']['from']['id'] group = app.db['users'].find_one({'name': user_id})['group'] cur_day = app.db['info'].find_one({'name': 'current_day'})['day'] cur_week = app.db['info'].find_one({'name': 'current_week'})['week'] return schedule_tools.get_schedule(group, cur_day, cur_week)
def tomorrow_schedule(request): group = re.findall(r'\d+', request['message']['text'])[-1] if not app.db['groups'].count_documents({'name': group}): return 'Invalid group number' cur_day = (app.db['info'].find_one({'name': 'current_day'})['day'] + 1) % 7 cur_week = (app.db['info'].find_one({'name': 'current_week'})['week'] + (cur_day == 0)) % 4 + (cur_day == 0) return schedule_tools.get_schedule(group, cur_day, cur_week)
def today_command(message): group_number = message['message']['text'].split()[-1] return get_schedule( app.db.schedules.date.find_one({'name': 'curr_day'})['curr_day'], app.db.schedules.date.find_one({'name': 'curr_week'})['curr_week'], group_number)