I have been writing a simple bot to delete messages from one group and to forward them to another, so while executing I get this error:
TeleBot.forward_message() got an unexpected keyword argument 'chatid'
I am new to bot making so any help would be appreciated.
Here is my code:
import telebot
from telebot import types
bot = telebot.TeleBot('token')
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, 'Hi, ready to delete')
if ':' not in message.text:
bot.forward_message(chatid='group chat id',
fromchatid=message.chat.id, messageid=message.message_id)
bot.delete_message(chatid=message.chat.id, messageid=message.message_id)
bot.polling(none_stop=True)
It seems like you may be missmatching the variable's nomenclature.
Based on PyTelegramBot documentation, forward_message() expects this params:
forward_message(chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, timeout: Optional[int] = None, message_thread_id: Optional[int] = None)
So your chatid should go like chat_id and the same goes with every other param.
Your snippet would go something like this:
bot.forward_message(chat_id='group chat id', from_chat_id=message.chat.id, message_id=message.message_id)
bot.delete_message(chat_id=message.chat.id, message_id=message.message_id)
Note: This nomenclature may be version dependant and was described as current latest (4.9.0).