python-telegram-bot

How to receive images from Telegram Bot [duplicate]

∥☆過路亽.° 提交于 2020-01-06 14:12:52
问题 This question already has an answer here : how save photo in telegram python bot? (1 answer) Closed last year . Can't receive images from my telegram bot, trying something like this: import telegram from telegram.ext import Updater from telegram.ext import MessageHandler from telegram.ext import Filters def photo_handler(bot, update): file = bot.getFile(update.message.photo.file_id) print ("file_id: " + str(update.message.photo.file_id)) file.download('photo.jpg') updater = Updater(token='my

Sending Telegram messages with Telethon: some entity parameters work, others don't?

狂风中的少年 提交于 2020-01-05 08:27:10
问题 I'm using Telethon's send_message function to send messages to various chats. Sometimes, the destination is another user (just a regular one on one chat), sometimes a group, sometimes a supergroup, and sometimes a channel (of which I'm admin). If I understand correctly, the syntax is supposed to be: client.send_message(entity,text) But I can't figure out what the entity parameter is supposed to be in different cases. What I find especially confusing is specifying an integer id seems to work

how to make my python telegram bot to send message at certain time every day?

岁酱吖の 提交于 2020-01-04 18:17:30
问题 I'm trying to make a bot which will be able to notify users at a certain time every day. how can I make bot to send notification at certain time every day? I've tried to use while loop but it s @bot.callback_query_handler(func=lambda c:True) def CalendarAnswer(c): Cid = c.message.chat.id if c.data == 'ShowTime': bot.send_message(Cid, timeToday) if c.data == 'ShowDate': bot.send_message(Cid, dateToday) if c.data == 'SetNotification': Ask = bot.send_message(Cid, 'Напиши мне время') bot.register

Multiple callback query handlers?

独自空忆成欢 提交于 2020-01-01 09:14:05
问题 Is it possible with the python-telegram-bot wrapper to use more than one callback query handler? I would like to have multiple unique handlers but as far as I can tell, there can only be one. This means I'd have to base which inline keyboards I show on the initiating message text. Is there something I'm missing? 回答1: You can use ConversationHandler wrapper for that. Check code bellow: from telegram import InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater,

Proper way to build menus with python-telegram-bot

一笑奈何 提交于 2020-01-01 04:52:29
问题 I work with python-telegram-bot and try to build a system of nested menus as BotFather bot does. For instance, you have a general bot menu where you can choose "Edit Bot" and get the new corresponding menu with an option to get back to the previous menu. I try to achieve that with code: # main menu def start(bot, update): menu_main = [[InlineKeyboardButton('Option 1', callback_data='m1')], [InlineKeyboardButton('Option 2', callback_data='m2')], [InlineKeyboardButton('Option 3', callback_data=

Can I store bot state data on the involved telegram chat itself?

无人久伴 提交于 2019-12-25 17:18:21
问题 I'm trying to store a bit of data regarding the bot's conversation within a group (i.e. the bot manages kind of a text-based chat scape room and I want to save which "world" and "stage" the group is in at the time), and so I was wondering whether you can just store this little amount of data within the chat itself (instead of saving it on the bot server side*, which seems quite a lot of work for something that should be so simple). So following this python zen philosophy, I'm trying to find a

Can I store bot state data on the involved telegram chat itself?

血红的双手。 提交于 2019-12-25 17:18:05
问题 I'm trying to store a bit of data regarding the bot's conversation within a group (i.e. the bot manages kind of a text-based chat scape room and I want to save which "world" and "stage" the group is in at the time), and so I was wondering whether you can just store this little amount of data within the chat itself (instead of saving it on the bot server side*, which seems quite a lot of work for something that should be so simple). So following this python zen philosophy, I'm trying to find a

Telegram-bot user control

不羁的心 提交于 2019-12-23 17:27:06
问题 I want to create a telegram bot for a home project and i wish the bot only talk to 3 people, how can I do this? I thought to create a file with the chat id of each of us and check it before responding to any command, I think it will work. the bot will send the correct info if it's one of us and "goodbye" to any other But is there any other way to block any other conversation with my bot? Pd: I'm using python-telegram-bot 回答1: For the first part of your question you can make a private group

How To Limit Access To A Telegram Bot

允我心安 提交于 2019-12-23 07:29:25
问题 When I send a message to my Telegram Bot, it responses with no problems. I wanna limit the access such that me and only me can send message to it. How can I do that? 回答1: As this question is related to python-telegram-bot, information below is related to it: When you add handlers to your bot's dispatcher, you can specify various pre-built filters (read more at docs, github) or you can create custom ones in order to filter incoming updates. To limit access to a specific user, you need to add

Calling a Telegram Token from an external file

纵饮孤独 提交于 2019-12-13 05:06:47
问题 I couldn't seem to find anything regarding this and I know I had a solution months ago. I want to write a Telegram Bot with python-telegram-bot to download videos from any (legal) website and send it to the user. The Bot should ask the User whether he wants a Video, Audio(mp3) or a GIF(mp4 w/o audio). This should happen via Inline Keyboard. I'm getting away from my initial question... I don't want to have the Token inside the script, as I might share it with others for more specific help. So