python-telegram-bot

How to read messages from Telegram group with bot?

两盒软妹~` 提交于 2019-12-12 18:08:24
问题 I would like to connect a simple telegram bot to read messages from a group, (where I'm not admin). I already added the bot to the group, but it doesn't work. Here is the code I have in Python: import telepot from pprint import pprint import time from telepot.loop import MessageLoop key = "MY API" bot = telepot.Bot(key) def handle(msg): pprint(msg) bot.message_loop(handle) while 1: time.sleep(10) If I open the chat (of the bot) and write a message, everything works well. But when someone send

How to create a telegram bot that only works for 30 days per user and then stops there?

与世无争的帅哥 提交于 2019-12-12 04:38:35
问题 I built a telegram bot with a Python-Telegram-bot module, and now I want to set it up to work only 30 days, that is, when the user sends the /start to the bot, the bot will stop for 30 days.my codes: # -*- coding: utf-8 -*- from telegram.ext import Updater, MessageHandler, Filters, CommandHandler import re def delete_method(bot, update): if not update.message.text: print("it does not contain text") return mlist=['hello', 'by', 'world'] for i in mlist: if re.search(i, update.message.text): bot

Telegram Bot Is Not Working

烂漫一生 提交于 2019-12-11 15:29:11
问题 I made a telegram bot with python-telegram-bot. I have defined a list of words for the bot and I want to manage the chat bot in the group. That is, if there is a word in the chat that is found in the defined list, the bot will delete it. I added the bot to a group and admin it there. The bot should control the messages sent to the group, and if there is a word in the message that is on the mlist, the bot should delete the message. my codes: # -*- coding: cp1256 -*- #!/usr/bin/python import os

What's the structure of Telegram's updates to webhook Flask app?

梦想的初衷 提交于 2019-12-11 07:48:53
问题 I'm trying to program a Telegram bot using webhook in a Flask app with telepot, in PythonAnywhere. And so, I want to know what's the structure of the updates comming from Telegram, so as to know what's there and how is it called, and use it in the bot, essentially. I've tried to log the message it receives to the console (though I'm not sure where the console should be on PythonAnywhere), and also to write in a file in the same server, through python, but that's not working either. #This that

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

浪尽此生 提交于 2019-12-10 00:30:40
问题 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? 回答1: 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,

Telegram bot to wait for user reply

久未见 提交于 2019-12-08 01:44:55
问题 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?"]

Read the messages of the public channels from Telegram

痞子三分冷 提交于 2019-12-07 12:55:22
问题 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? 回答1: Assuming you're

Handle multiple questions for Telegram bot in python

时间秒杀一切 提交于 2019-12-07 06:10:53
问题 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

Telegram bot api keyboard

孤人 提交于 2019-12-07 02:50: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? 回答1: According to the Bot API documentations, a custom keyboard requires a reply_markup parameter, whose

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

假如想象 提交于 2019-12-06 19:30:14
问题 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. 回答1: 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