python-telegram-bot

Telegram bot to wait for user reply

梦想与她 提交于 2019-12-06 04:52:04
The code below is for a Telegram Bot which basically takes a person username and password and verifies it to provide his average expenditures. The problem as we see is the bot waits for the user to send his username and password for 10 sec either waste of time (or) not sufficient time was given. How could I program such that the bot waits for user message and then executes the next lines ( wait till the trigger ) def highest(intent,chatid,text): seq=["What is your Username ?","Password?"] send_message(seq[0],chatid) time.sleep(6) name,chatid = reply_function() print name send_message(seq[1]

Read the messages of the public channels from Telegram

随声附和 提交于 2019-12-05 21:50:38
I need to read the messages of some public channels in the application, as for example it happens https://tlgrm.ru/channels/tech As I understood, the bot for this business will not work. You need to use client api, but everywhere that with the channel methods are connected everywhere you need channel_id but where do I get it I do not know, I only have channel names, and how do I get it from it id I did not find such a method. How can I get the channel's id by its name? Assuming you're using python, I suggest Telethon library. You can use this piece of code to get channel_id and access_hash

How to join my Telegram Bot to PUBLIC channel

送分小仙女□ 提交于 2019-12-05 21:43:12
问题 My question is: how to join my telegram bot to a telegram public channel that I am not administrator of it, and without asking the channel's admin to add my bot to the channel? maybe the chatId of channel or thru link of channel? Thank you in advance :) edit------ I have heard that some people claim to do this join their bot to channels, and scrape data. So if Telegram does not allow it, how can they do it? can you think of any work around? Appreciate your time? 回答1: Till today, only the

Handle multiple questions for Telegram bot in python

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:44:11
I'm programming a telegram bot in Python using the Telegram bot API. I'm facing the problem of managing questions that need an answer of the user. The problem arises when the program is waiting for an answer of one user and another user request information or ask another question before the first user responds. The Telegram API uses a code to handle the request. When you ask for updates you include a code. If the code you send is higher than a request code, it is mark as handled and telegram delete it and no longer appears in the updates. This code is sequential, so if you mark update 3 as

Telegram bot api keyboard

依然范特西╮ 提交于 2019-12-05 04:54:40
I have problem with Telegram Bot Api and with "ReplyKeyboard". I'm using Python 2.7 and I send post request: TelegramAPI.post(TELEGRAM_URL + "sendMessage", data=dict(chat_id=CHAT_ID, text="", keyboard={'keyboard': keyboard, 'one_time_keyboard': False, 'resize_keyboard': True}) keyboard in this format: [["A button"], ["B button"]] But in Telegram I don't see keyboard. What problem can be? According to the Bot API documentations , a custom keyboard requires a reply_markup parameter, whose value is a JSON-serialized specification of the keyboard. Assuming your TelegramAPI.post() function does not

How can I send a message to someone with my telegram bot using their Username

Deadly 提交于 2019-12-05 00:43:19
I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number). I wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '@'), Also if there is a way to convert a username to a UserID. You can't send message to users using their username that is in form of @username , you can just send messages to channel usernames which your bot is administrator of it. Telegram bot api uses chat_id identifier for sending messages. If you want to achieve chat_id of

How can I redirect messages from telegram channels that are in certain format?[telegram bot]

丶灬走出姿态 提交于 2019-12-04 21:11:57
I have many telegram channels, 24\7 they send messages in the format "buy usdjpy sl 145.2 tp 167.4" "eurusd sell sl 145.2 tp 167.4" "eurusd sl 145.2 tp 167.4 SELL" or these words in some order My idea is to create app that checks every channel's message, and redirects it to my channel if it is in the above format. Does telegram api allow it? I solved a similar problem with TdLib . Their GitHub site has full C++, Java and C# examples that you can just modify. I worked on the Java example, and applied most of my changes to the UpdatesHandler.onResult method (line 353). The C++ and C# examples

Multiple callback query handlers?

徘徊边缘 提交于 2019-12-04 03:16:43
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? You can use ConversationHandler wrapper for that. Check code bellow: from telegram import InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, ConversationHandler TELEGRAM_HTTP_API_TOKEN = 'PASTE_TELEGRAM_HTTP_API_TOKEN'

How to join my Telegram Bot to PUBLIC channel

久未见 提交于 2019-12-04 02:47:48
My question is: how to join my telegram bot to a telegram public channel that I am not administrator of it, and without asking the channel's admin to add my bot to the channel? maybe the chatId of channel or thru link of channel? Thank you in advance :) edit------ I have heard that some people claim to do this join their bot to channels, and scrape data. So if Telegram does not allow it, how can they do it? can you think of any work around? Appreciate your time? Till today, only the Channel Creator can add a bot (as Administrator or Member) to the Channel, whether public or private. Even the

How to convert Telegram voice in a wave file in python

ぃ、小莉子 提交于 2019-12-02 15:57:47
问题 I'm trying to save a Telegram voice file in a wave audio file using soundfile library: def ReceiveVoice(bot, update, user_data): voice = bot.getFile(update.message.voice.file_id) voice.download('file.ogg') data, samplerate = sf.read('file.ogg') sf.write('file.wav', data, samplerate) But I'm receiving the following error: File "C:\Python27\lib\site-packages\soundfile.py", line 257, in read subtype, endian, format, closefd) as f: File "C:\Python27\lib\site-packages\soundfile.py", line 624, in _