def get_actual_currency_rate_for_alarm(user): db_user_alarm_currency_rate = DBConnector( ).get_db_user_alarm_currency_rate(user.user_id) today_currency_rate = get_today_currency_rate() if db_user_alarm_currency_rate: return today_currency_rate, db_user_alarm_currency_rate return today_currency_rate, today_currency_rate
def football_start(message): user = User.get_user(user_id=message.chat.id) sent_football_message( user, MSG_FOOTBALL_BASE_CMD, get_message_keyboard(*[{ k: v } for (k, v) in bot_config.buttons_football_leagues.items()])) DBConnector().insert_analytics(user, message.text)
def football_country_leagues(call): logger().info("Button '{}'".format(call.data)) user = User.get_user(user_id=call.from_user.id) actual_buttons_football = { **bot_config.buttons_football_country_leagues } # new dict instance sent_football_message( user, MSG_FOOTBALL_BASE_CMD, get_message_keyboard(*[{ k: v } for (k, v) in actual_buttons_football.items()])) DBConnector().insert_analytics(user, call.data)
def job(): users = DBConnector().get_db_users_alarm_currency_rate() for user in users: today_currency_rate = get_today_currency_rate() if today_currency_rate >= user['alarm_rate']: actual_buttons_currency_selection = dict( bot_config.buttons_currency_selection) del actual_buttons_currency_selection[ bot_config.currency_dollar_id] bot.send_message(chat_id=user['id'], text=f""" <b>Currency Alarm</b> {get_currency_message(bot_config.currency_dollar_id)}""", reply_markup=get_message_keyboard( bot_config.button_currency_graph, actual_buttons_currency_selection, bot_config.button_currency_alarm), parse_mode=ParseMode.HTML)
def set_currency_alarm_rate(user, call): call_message = call.message.text.strip() currency_alarm_rate = find_all_by_regexp(call_message, currency_alarm_rate_regexp)[0] new_currency_alarm_rate = round(eval(currency_alarm_rate + call.data), 1) new_currency_alarm_rate_for_replace = "<b>{}</b>".format( new_currency_alarm_rate) message = re.sub(currency_alarm_rate_regexp, new_currency_alarm_rate_for_replace, call_message) def send_currency_alarm_message(message): bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text=message, reply_markup=get_message_keyboard(buttons_currency_alarm_rate), parse_mode=ParseMode.HTML) send_currency_alarm_message(message) DBConnector().insert_currency_alarm(user, new_currency_alarm_rate)
def instagram_start(message): user = User.get_user(user_id=message.chat.id) bot.send_message(user.user_id, MSG_INSTAGRAM_BOT) DBConnector().insert_analytics(user, message.text)
def get_user(cls, user_id): user_db = DBConnector().get_db_user(user_id=user_id) logger().info(f"***** {user_db} *****") return cls(user_db=user_db)
def geo_start(message): user = User.get_user(user_id=message.chat.id) geo_request(user) DBConnector().insert_analytics(user, message.text)
def instagram_post_content(message): user = User.get_user(user_id=message.chat.id) send_to_user_insta_post_media_content( InstaPost(post_url=message.text, message_id=message.message_id), user) DBConnector().insert_analytics(user, 'insta_link')
def currency_start(message): user = User.get_user(user_id=getattr(message, 'message', message).chat.id) actual_currency = getattr(message, 'data', bot_config.currency_dollar_id) send_currency_rate(user, actual_currency) DBConnector().insert_analytics(user, BASE_CMD_CURRENCY)
def cinema(message): user = User.get_user(user_id=message.chat.id) send_cinema_list(user) DBConnector().insert_analytics(user, message.text)
def football_calendar(call): logger().info("Button '{}'".format(call.data)) user = User.get_user(user_id=call.from_user.id) send_football_calendar(user, call.data) DBConnector().insert_analytics(user, call.data)
def start(message): user = User.fetch_user(chat=message.chat) start_step(user) DBConnector().insert_analytics(user, message.text)
def fetch_user(chat: Chat): user = DBConnector().get_db_user(chat.id) if not user: DBConnector().insert_user(chat) return User.get_user(user_id=chat.id)
def cinema_soon_call(call): logger().info("Button '{}'".format(call.data)) user = User.get_user(user_id=call.from_user.id) send_cinema_soon_list(user) DBConnector().insert_analytics(user, call.data)
def currency_graph_call(call): logger().info("Button '{}'".format(call.data)) user = User.get_user(user_id=call.from_user.id) send_currency_graph(user, call.message) DBConnector().insert_analytics(user, bot_config.currency_graph)
def location(message): user = User.get_user(user_id=message.chat.id) if message.location is not None: send_map_location(bot, user, message) DBConnector().insert_analytics(user, message.text)
def virus(message): user = User.get_user(user_id=message.chat.id) sent_virus_data(user) DBConnector().insert_analytics(user, message.text)