def callback_warn(c): db_votelist_update(c.from_user.id) someID = db_votelist_get(c.from_user.id) # list of ids to vote currID = int(someID[0]) if currID is None: bot.send_message(c.from_user.id, constants.NO_NEW_PHOTOS) return bot.send_chat_action(c.from_user.id, 'upload_photo') usrrand = db_rand_get(c.from_user.id) idtovote = db_ph_get(currID, usrrand) bot.send_photo(c.from_user.id, idtovote, reply_markup=pages_keyboard(currID))
def process_photo(message): status_db1 = db_ph_get(message.from_user.id, 1) status_db2 = db_ph_get(message.from_user.id, 2) status_db3 = db_ph_get(message.from_user.id, 3) if status_db1 == constants.DB_EMPTY_STR: bot.send_chat_action(message.from_user.id, constants.BOT_ACTION_TYPING) file_id = message.photo[len(message.photo) - 1].file_id db_ph_set(message.from_user.id, 1, file_id) bot.send_message(message.from_user.id, constants.PHOTO_FIRST_SUCCESS) else: if status_db2 == constants.DB_EMPTY_STR: bot.send_chat_action(message.from_user.id, constants.BOT_ACTION_TYPING) file_id = message.photo[len(message.photo) - 1].file_id db_ph_set(message.from_user.id, 2, file_id) bot.send_message(message.from_user.id, constants.PHOTO_SECOND_SUCCESS) else: if status_db3 == constants.DB_EMPTY_STR: bot.send_chat_action(message.from_user.id, constants.BOT_ACTION_TYPING) file_id = message.photo[len(message.photo) - 1].file_id db_ph_set(message.from_user.id, 3, file_id) bot.send_message(message.from_user.id, constants.PHOTO_THIRD_SUCCESS) else: bot.send_chat_action(message.from_user.id, constants.BOT_ACTION_TYPING) bot.send_message(message.from_user.id, constants.PHOTO_UPLOAD_LIMIT_FAIL)
def callback_like(c): bot.delete_message(chat_id=c.message.chat.id, message_id=c.message.message_id) db_vote_set(c.from_user.id, db_vote_get(c.from_user.id) + 1) nowid = int(c.data[-9:]) db_like_set(nowid, db_like_get(nowid) + 1) cvlst = db_value_get(c.from_user.id, "votedlist") if cvlst is not None: # Get current votedlist db_value_set(c.from_user.id, "votedlist", cvlst + str(nowid) + '\n') else: db_value_set(c.from_user.id, "votedlist", str(nowid) + '\n') bot.send_chat_action(c.from_user.id, 'upload_photo') currID = db_vote_not_voted_get(c.from_user.id) if currID is None: bot.send_message(c.from_user.id, constants.NO_NEW_PHOTOS) return usrrand = db_rand_get(c.from_user.id) idtovote = db_ph_get(currID, usrrand) bot.send_photo(c.message.chat.id, idtovote, reply_markup=pages_keyboard(currID))
def main_menu(m): if m.text == constants.MENU_RATE: db_votelist_update(m.from_user.id) bot.send_chat_action(m.from_user.id, constants.BOT_ACTION_PH_UPLOAD) someID = db_votelist_get(m.from_user.id) notID = db_votedlist_get(m.from_user.id) ntrsc = intersection(someID, notID) if len(ntrsc) == someID: bot.send_message(m.from_user.id, constants.NO_NEW_PHOTOS) return else: for t in ntrsc: someID.remove(t) try: currID = int(someID[0]) usrrand = db_rand_get(m.from_user.id) idtovote = db_ph_get(currID, usrrand) bot.send_photo(m.from_user.id, idtovote, reply_markup=pages_keyboard(currID)) except IndexError: bot.send_message(m.from_user.id, constants.NO_NEW_PHOTOS) if m.text == constants.MENU_HELP: bot.send_chat_action(m.from_user.id, constants.BOT_ACTION_TYPING) bot.send_message(m.from_user.id, constants.HELP_TEXT, reply_markup=reg_keyboard()) if m.text == constants.MENU_PROFILE: if db_vote_get(m.from_user.id) is not None: if db_vote_get(m.from_user.id) < 5: bot.send_message(m.from_user.id, constants.POINTS_NOT_ENOUGH, reply_markup=warn_key(m.from_user.id)) else: bot.send_message(m.from_user.id, constants.POINTS_ENOUGH, reply_markup=lnk_key(m.from_user.id))
month_now = "0" + month_now if len(day_now) == 1: day_now = "0" + day_now # ----------------------------------------------------------------------------------------------------------- cursor.execute("SELECT User_Id, Chat_Id FROM birthdays WHERE DATE_FORMAT(Birthday, '%m.%d') = {}" .format(month_now + "." + day_now)) birthdays = cursor.fetchall() for birthday in birthdays: script_directory = os.path.dirname(os.path.abspath(__file__)) user_who_has_birthday_id, chat = birthday try: bot.send_chat_action(chat, 'typing') except telebot.apihelper.ApiException: sql = "DELETE FROM birthdays WHERE Chat_Id = %s" val = (chat,) cursor.execute(sql, val) db.commit() continue # Get user_who_has_birthday profile photo user_profile_photos = bot.get_user_profile_photos(user_who_has_birthday_id, limit=1).photos if not user_profile_photos: bot.send_message(chat, "Looks like somebody doesn't have the profile photo..." "\nHow is it possible not to have the profile photo in twenty first century.." "\nMaybe it's just a new user.. And it's probably hard to choose the nice one..." "\nOh.. " "\nYea, right! I can help to choose!! How about this one?!") user_profile_photos = bot.get_user_profile_photos(constants.bot_id, limit=1).photos
def imageButtonAction(chatContext): bot.send_chat_action(chatContext.chatId, "upload_photo") if not chatContext.imageURLs: chatContext.imageURLs = getImageURLs(chatContext.word) return bot.send_photo(chatContext.chatId, chatContext.getNextImageURL())
def giphyButtonAction(chatContext): bot.send_chat_action(chatContext.chatId, "upload_photo") return bot.send_document(chatContext.chatId, getGiphy())