queryId, chatId, queryString = glance(msg, flavor='inline_query') user = User.get(chatId=chatId) results = inline.inlineResults(user, queryString) bot.answerInlineQuery(queryId, results, cache_time=10, is_personal=True, switch_pm_text="Create a new Clip", switch_pm_parameter="newclip_inline") def incoming_message(msg): Thread(target=reply, args=[msg]).start() def incoming_button(msg): Thread(target=button, args=[msg]).start() def incoming_query(msg): Thread(target=query, args=[msg]).start() bot.message_loop({ 'chat': incoming_message, 'callback_query': incoming_button, 'inline_query': incoming_query }) while True: sleep(60)
"Il bot è attualmente in manutenzione per problemi con ClasseViva, e tutte le sue " "funzioni sono temporaneamente disabilitate.\n" "Non eliminare questa chat: se vuoi puoi archiviarla su Telegram, così appena " "ci saranno notizie arriverà un messaggio qui.\n\n" "/moreinfo", parse_mode="HTML") def accept_message(msg): Thread(target=reply, name=f"msg_{msg['chat']['id']}", args=[msg]).start() def accept_button(msg): Thread(target=button_press, name=f"btn_{msg['from']['id']}", args=[msg]).start() bot.message_loop(callback={ 'chat': accept_message, 'callback_query': accept_button }) while True: sleep(60) now = datetime.now() doLongFetch = now.strftime("%H:%M") == js_settings["fullUpdatesTime"] if now.minute % updatesEvery == 0: helpers.renewProxy() runDailyUpdates(now) runUpdates(long_fetch=doLongFetch)
chatId = msg['from']['id'] text = msg['text'] name = msg['from']['first_name'] if not User.exists(lambda u: u.chatId == chatId): User(chatId=chatId) user = User.get(chatId=chatId) if text.startswith("/geticon"): params = text.split(2) bot.sendPhoto( chatId, api.getIcon(params[1], params[2] if len(params) > 2 else None)) else: bot.sendMessage( chatId, "Hey, <b>{}</b>!\nThis bot is still under development, check later..." .format(name), parse_mode="HTML") def accept_message(msg): Thread(target=reply, args=[msg]).start() bot.message_loop({'chat': accept_message}) while True: sleep(60)
elif text == "backsearch": bot.editMessageText((chatId, message_id), "🔍 <b>Book Search</b>\n" "Pick a category from the list below:", parse_mode="HTML", reply_markup=keyboards.search_cat(message_id)) elif text == "moveall": bot.editMessageReplyMarkup((chatId, message_id), keyboards.manageBooks("move", message_id, show_all=True)) elif text == "delall": bot.editMessageReplyMarkup((chatId, message_id), keyboards.manageBooks("del", message_id, show_all=True)) def incoming_message(msg): Thread(target=reply, args=[msg]).start() def incoming_query(msg): Thread(target=button, args=[msg]).start() bot.message_loop({'chat': incoming_message, 'callback_query': incoming_query}) while True: sleep(60)
description=desc, thumb_url="https://i.imgur.com/Nc7b9Yx.png") ] bot.answerInlineQuery(queryId, results, cache_time=10800, is_personal=False) def accept_message(msg): Thread(target=reply, args=[msg]).start() def accept_button(msg): Thread(target=button_press, args=[msg]).start() def incoming_query(msg): Thread(target=query, args=[msg]).start() bot.message_loop( callback={ 'chat': accept_message, 'callback_query': accept_button, 'inline_query': incoming_query }) while True: sleep(60)
# Invalid link elif queryString.strip() != "": linkSha256 = sha256(queryString.encode()).hexdigest() results = [ InlineQueryResultArticle( id=linkSha256, title="Invalid link", input_message_content=InputTextMessageContent( message_text=queryString, disable_web_page_preview=True), description= "Invalid link. Type an Amazon link to short it (or tap to send anyway)", thumb_url="https://i.imgur.com/7eAooJr.jpg") ] bot.answerInlineQuery(queryId, results, cache_time=3600, is_personal=False) def incoming_message(msg): Thread(target=reply, args=[msg]).start() def incoming_query(msg): Thread(target=query, args=[msg]).start() bot.message_loop({'chat': incoming_message, 'inline_query': incoming_query}) while True: sleep(60)
bot.deleteMessage((chatId, msgId)) def button(msg): chatId = msg["message"]["chat"]["id"] userName = msg["from"]["first_name"] msgId = msg["message"]["message_id"] data = msg["data"] command = data.split("#")[0] params = data.split("#")[1:] if command == "prenotaLink": domain, linkId = params msgText = msg["message"]["text"] newText = msgText.replace("Nuova offerta segnalata!", "<b>[Prenotata da {}]</b>".format(userName)) bot.editMessageText( (chatId, msgId), newText, parse_mode="HTML", disable_web_page_preview=True, reply_markup=keyboards.open_scontino(domain, linkId)) bot.message_loop({'chat': reply, 'callback_query': button}) while True: sleep(60) clock = datetime.now().strftime("%H:%M") if clock == "02:00": Thread(target=runDatabaseUpdate, name="databaseUpdater").start()