eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.02k stars 2.02k forks source link

BUG. Telebot deletes messages sent by user but it should not! #1152

Closed roman-smolnyk closed 3 years ago

roman-smolnyk commented 3 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using? pyTelegramBotAPI 3.7.7

  2. What OS are you using? Windows 10 and Ubuntu server

  3. What version of python are you using? 3.9

Telebot deletes messages sent by user if in reply to this message bot should send markdown message with specific link(why is it specific I don't know :) ). It also doesn't send any messages to user in reply(but it should). No errors. My code:

import telebot
import logging

logger = telebot.logger
logging.getLogger(logger.name).setLevel(logging.DEBUG)

TOKEN = "YOUR TOKEN HERE"
MAN_LINK = "https://telegra.ph/Dynalist-bot-02-09"
ALERT = "*Do not use this functonality in groups*"
NO_USER = f"*You are not registred. How to do that? Please, read* [manual]({MAN_LINK})"  #

bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=["my_settings"])
def run_message(message):
    logger.debug(f"MY SETTINGS COMMAND")
    mcid = message.chat.id
    mid = message.message_id
    if message.chat.type == "group":
        bot.send_message(mcid, ALERT, parse_mode="Markdown")
        return

    user_data = {}
    if not user_data:
        bot.send_message(mcid, NO_USER, parse_mode="Markdown")
        return
    reply = "REPLY"
    bot_message = bot.send_message(mcid, f"`{reply}`", parse_mode="Markdown")

logger.info("BOT STARTED LOCALLY")
bot.delete_webhook()
bot.polling(none_stop=True)
Badiboy commented 3 years ago

Both code and logs shows that bot does nothing wrong. Bot does "sendMessage" and Telegram confirms that new message created, nothing else.

Can you create and post here a standalone test case that will reproduce the problem? Withour any additional code.

iAkashPattnaik commented 3 years ago

@poma23324 , seriously? STOP deleting the messages yourself and blaming the framework.. If you have a userbot kind of stuff, better check if isn't it what's deleting messages?

By the way, i liked the way you did it.

My code isn't working?
No worries, 
    lets blame the framework.
roman-smolnyk commented 3 years ago

Badiboy

Here is a code with this bug. I have noticed that if I change telegraph link to another one, everything works fine, but exactly with my link, bot deletes any message that was sent by user or bot, during bot session alive.

import telebot
import logging

logger = telebot.logger
logging.getLogger(logger.name).setLevel(logging.DEBUG)

TOKEN = "YOUR TOKEN HERE"
MAN_LINK = "https://telegra.ph/Dynalist-bot-02-09"
ALERT = "*Do not use this functonality in groups*"
NO_USER = f"*You are not registred. How to do that? Please, read* [manual]({MAN_LINK})"  #

bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=["my_settings"])
def run_message(message):
    logger.debug(f"MY SETTINGS COMMAND")
    mcid = message.chat.id
    mid = message.message_id
    if message.chat.type == "group":
        bot.send_message(mcid, ALERT, parse_mode="Markdown")
        return

    user_data = {}
    if not user_data:
        bot.send_message(mcid, NO_USER, parse_mode="Markdown")
        return
    reply = "REPLY"
    bot_message = bot.send_message(mcid, f"`{reply}`", parse_mode="Markdown")

logger.info("BOT STARTED LOCALLY")
bot.delete_webhook()
bot.polling(none_stop=True)
roman-smolnyk commented 3 years ago

akashjio66666@gmail.com

Before opening an issue I have inspected in details my code and there were no my mistakes. And unlike you, I check everything twice before sending or saying something. Because I'm sure that my words have some value, as I produce only checked information. And you, blamed me, without checking the code, so your word's value = None. Your useless commends do not worth to be present in this topic. Shut up and check information twice!!!

iAkashPattnaik commented 3 years ago

@poma23324 , do you have a userbot?

btw, why is bot.delete_webhook() used which is unnecessary?

roman-smolnyk commented 3 years ago

@BLUE-DEVIL1134

What do you mean under "userbot"? is it something different from usual telegram bot? bot.delete_webhook() - not necessary. It was used in long past as I have used one bot for production and debugging, now I have 2 different

iAkashPattnaik commented 3 years ago

@BLUE-DEVIL1134

What do you mean under "userbot"? is it something different from usual telegram bot? bot.delete_webhook() - not necessary. It was used in long past as I have used one bot for production and debugging, now I have 2 different

userbots are illegal use of telegram ids with mtproto libs nothing usual with bots...

seems some other problem

Badiboy commented 3 years ago

Code from https://github.com/eternnoir/pyTelegramBotAPI/issues/1152#issuecomment-836324230 works fine for me. I see no problems.

image

roman-smolnyk commented 3 years ago

Now I also can't reproduce it, but yesterday this code worked incorrectly. I should make video next time, my fault. Maybe it was some bug on telegram side.