python-telegram-bot

Pretending that telegram bot is typing?

自闭症网瘾萝莉.ら 提交于 2021-02-11 14:12:09
问题 How can I make a bot to pretend that it is typing a message? The following text appears in the chat when the bot pretend to type: I use the python aiogram framework but a suggestion for the native Telegram API would be also helpful. 回答1: I seriously suggest using the python-telegram-bot library which has an extensive Wiki. The solution for what you want is described in code snippets. You can manually send the action: bot.send_chat_action(chat_id=chat_id, action=telegram.ChatAction.TYPING) Or

How to add URL to InlineKeyboardButton for Telegram Bot

此生再无相见时 提交于 2021-02-10 18:10:32
问题 I would like to make the button that will open URL (external hyperlink) in browser from Telegram chat. Currently, I developed only clickable action buttons. update.message.reply_text( 'Subscribe to us on Facebook and Telegram:', reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton(text='on Facebook', callback_data='Facebook')], [InlineKeyboardButton(text='on Telegram', callback_data='Telegram')], ]) ) But how to make them as link (with arrow). I want to ask for users for sharing. 回答1:

How to add URL to InlineKeyboardButton for Telegram Bot

微笑、不失礼 提交于 2021-02-10 18:02:36
问题 I would like to make the button that will open URL (external hyperlink) in browser from Telegram chat. Currently, I developed only clickable action buttons. update.message.reply_text( 'Subscribe to us on Facebook and Telegram:', reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton(text='on Facebook', callback_data='Facebook')], [InlineKeyboardButton(text='on Telegram', callback_data='Telegram')], ]) ) But how to make them as link (with arrow). I want to ask for users for sharing. 回答1:

Making a Python-Telegram-Bot persistent

你说的曾经没有我的故事 提交于 2021-02-10 04:21:11
问题 I recently coded a simple telegram bot using the python-telegram-bot library, and deployed this bot on Heroku. Now i'm looking for an effective way to make the bot persistent, allowing it to store Bot_data and user_data between runs. I took a look at the persistence classes the library offers and i understood that PicklePersistence would not work with heroku's "ephemeral" hard drive. My question is, how can i implement the bot's persistence to make it work on heroku? Should i give up storing

Making a Python-Telegram-Bot persistent

偶尔善良 提交于 2021-02-10 04:12:41
问题 I recently coded a simple telegram bot using the python-telegram-bot library, and deployed this bot on Heroku. Now i'm looking for an effective way to make the bot persistent, allowing it to store Bot_data and user_data between runs. I took a look at the persistence classes the library offers and i understood that PicklePersistence would not work with heroku's "ephemeral" hard drive. My question is, how can i implement the bot's persistence to make it work on heroku? Should i give up storing

Making a Python-Telegram-Bot persistent

大兔子大兔子 提交于 2021-02-10 04:10:24
问题 I recently coded a simple telegram bot using the python-telegram-bot library, and deployed this bot on Heroku. Now i'm looking for an effective way to make the bot persistent, allowing it to store Bot_data and user_data between runs. I took a look at the persistence classes the library offers and i understood that PicklePersistence would not work with heroku's "ephemeral" hard drive. My question is, how can i implement the bot's persistence to make it work on heroku? Should i give up storing

How to send telegram mediaGroup with caption/text

痞子三分冷 提交于 2021-02-08 14:59:27
问题 I'm currently using python-telegram-bot and basically what I want to achieve with it is to send telegram messages like this: So the message consists of 2+ photos/videos with text message underneath. What I've already tried: sending message with send_message method, and including photo URLs, but it only shows 1 picture which is under the text sending media group using send_media_group, but this method has no caption parameter as send_photo. 回答1: You should use sendMediaGroup, where you can

How to send a message with discord.py from outside the event loop (i.e. from python-telegram-bot thread)?

∥☆過路亽.° 提交于 2021-02-08 06:13:24
问题 I want to use make a bot that communicates between discord and telegram by using the libraries python-telegram-bot and discord.py (version 1.0.0). However the problem is that discord.py uses async functions and python-telegram-bot threading. With the code below, everything works fine for messages being posted in discord (the bot sends them correctly to telegram), however the other way around does not work (bot gets messages from telegram and sends it to discord). I previously had issues with

Python telegram bot: Access to contact information

邮差的信 提交于 2021-02-08 05:08:05
问题 Following code requests location and contact from user: def contact(bot, update): dp = DjangoTelegramBot.dispatcher con_keyboard = KeyboardButton(text="send_contact", request_contact=True) loc_keyboard = KeyboardButton(text="send_location", request_location=True) custom_keyboard = [[ con_keyboard ,loc_keyboard]] reply_markup = ReplyKeyboardMarkup(custom_keyboard) bot.sendMessage(update.message.chat_id, text="Would you mind sharing your location and contact with me", reply_markup=reply_markup)

Python telegram bot: Access to contact information

强颜欢笑 提交于 2021-02-08 05:03:51
问题 Following code requests location and contact from user: def contact(bot, update): dp = DjangoTelegramBot.dispatcher con_keyboard = KeyboardButton(text="send_contact", request_contact=True) loc_keyboard = KeyboardButton(text="send_location", request_location=True) custom_keyboard = [[ con_keyboard ,loc_keyboard]] reply_markup = ReplyKeyboardMarkup(custom_keyboard) bot.sendMessage(update.message.chat_id, text="Would you mind sharing your location and contact with me", reply_markup=reply_markup)