def handle_docs_video(message): user = User(user_id=message.from_user.id, chat_id=message.chat.id, name=message.from_user.first_name) user.check_if_user_exists() print('Server time ', datetime.datetime.today()) if int(datetime.datetime.fromtimestamp(message.date).strftime("%H")) > 2: user.check_planked_today( datetime.datetime.fromtimestamp(message.date).strftime("%d %b %Y")) else: user.check_planked_today( (datetime.datetime.fromtimestamp(message.date) - timedelta(days=1)).strftime("%d %b %Y")) if user.planked_today is False: if int(datetime.datetime.fromtimestamp( message.date).strftime("%H")) > 2: if message.video.duration >= user.current_time: bot.send_message( message.chat.id, bot_planked_answer( message.from_user.first_name, datetime.datetime.fromtimestamp(message.date), user.politeness)) user.write_planked_today( datetime.datetime.fromtimestamp( message.date).strftime("%d %b %Y")) else: bot.send_message( message.chat.id, 'Dear ' + message.from_user.first_name + ', your current minimum planking time is ' + str(user.current_time) + ' seconds. Your video is ' + str(message.video.duration) + ' seconds, which is less.') bot.send_sticker( message.chat.id, 'CAACAgIAAxkBAAECQv9gkkGyCEsBZZL4RnkOD4A4fXLnKwACiwIAAladvQr3tGImDY878x8E' ) else: if message.video.duration >= user.current_time: bot.send_message( message.chat.id, bot_planked_answer( message.from_user.first_name, (datetime.datetime.fromtimestamp(message.date) - timedelta(days=1)), user.politeness)) else: bot.send_message( message.chat.id, 'Dear ' + message.from_user.first_name + ', your current minimum planking time is ' + str(user.current_time) + ' seconds. Your video is ' + str(message.video.duration) + ' seconds, which is less.') else: bot.send_message(message.chat.id, 'Bro, you already planked today! You can stop)')
def send_daily_stats(days=1): users_df = pd.read_hdf(users_db_path, key='df') for chat in users_df['chat_id'].drop_duplicates(): message = 'Daily check list as of ' + \ str((datetime.datetime.today().date() - timedelta(days=days)).strftime("%d %b %Y")) + ': \n ' for user in users_df.loc[users_df['chat_id'] == chat]['user_id']: print('Showing current user: '******' - ' + str( check_user.planked_today) + ' \n ' bot.send_message(chat, message)
def set_up_planked_with_step(message): users = load_chat_users(chat_id=message.chat.id) markup = types.ReplyKeyboardRemove() if message.text in users: user_to_change_plank = User(user_id=users[message.text], chat_id=message.chat.id) user_to_change_plank.check_if_user_exists() user_to_check = User(user_id=message.from_user.id, chat_id=message.chat.id) user_to_check.check_if_user_exists() if int(datetime.datetime.fromtimestamp( message.date).strftime("%H")) > 2: user_to_check.check_planked_today( datetime.datetime.fromtimestamp( message.date).strftime("%d %b %Y")) if user_to_check.planked_today is True: user_to_change_plank.check_planked_today( datetime.datetime.fromtimestamp( message.date).strftime("%d %b %Y")) if user_to_change_plank.planked_today is False: bot.send_message(message.chat.id, 'Great! Hope you and ' + str(user_to_change_plank.name) + ' had a wonderful time!', reply_markup=markup) user_to_change_plank.write_planked_today( datetime.datetime.fromtimestamp( message.date).strftime("%d %b %Y")) else: bot.send_message( message.chat.id, 'I see that this user already planked today. ' 'Did you get drunk together and you forgot that you have already tagged your friend?)', reply_markup=markup) else: bot.send_message( message.chat.id, 'Hmmm... It looks like you have not planked yourself today.. Do not believe you.', reply_markup=markup) else: user_to_check.check_planked_today( (datetime.datetime.fromtimestamp(message.date) - timedelta(days=1)).strftime("%d %b %Y")) if user_to_check.planked_today is True: user_to_change_plank.check_planked_today( (datetime.datetime.fromtimestamp(message.date) - timedelta(days=1)).strftime("%d %b %Y")) if user_to_change_plank.planked_today is False: bot.send_message(message.chat.id, 'Great! Hope you and ' + str(user_to_change_plank.name) + ' had a wonderful time!', reply_markup=markup) user_to_change_plank.write_planked_today( (datetime.datetime.fromtimestamp(message.date) - timedelta(days=1)).strftime("%d %b %Y")) else: bot.send_message( message.chat.id, 'I see that this user already planked today. ' 'Did you get drunk together and you forgot that you have already tagged your friend?)', reply_markup=markup) else: bot.send_message( message.chat.id, 'Hmmm... It looks like you have not planked yourself today.. Do not believe you.', reply_markup=markup) else: bot.send_message(message.chat.id, 'Bloody hell!!! There is no such user. Start over.', reply_markup=markup)