Relative Content

Tag Archive for pythontelegram-bottelebot

How to process a message in a telegram channel in python?

I’m writing a bot that will monitor the Telegram channel and perform certain manipulations in case of a new publication there. The bot is connected to the channel and has administrator rights. In the BotFather settings, message permissions are also enabled. I tried to implement this through the channel_post_handler, but the bot does not react to new messages in the channel, although it can leave them. There are no errors in the console.

Not working channel_post_handler what could be the problem?

import telebot BOT_TOKEN = ‘TOKEN’ bot = telebot.TeleBot(BOT_TOKEN) @bot.channel_post_handler(content_types=[‘text’]) def handle_channel_message(message): print(‘good!’) bot.polling() The bot has been added to the channel admin, but for some reason the handler “channel_post_handler” is not working. what could be the problem? python telegram-bot telebot New contributor Pol York is a new contributor to this site. Take care in asking […]

Telebot bot.get_chat_member(chat_id, user_id) throws an error

def is_sub(channel_id, user_id): try: chat_member = bot.get_chat_member(chat_id=channel_id, user_id=user_id) return True #return chat_member.status in ['member', 'administrator', 'creator'] except ApiTelegramException as e: print(e) return False
Error:
A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: user not found False
How to solve the problem? Why doesn’t it find the chat? pls help. If anything, I added the bot to the chat by the admin