I'm writing a Telegram bot using the python-telegram-bot library.
The bot should send a message to the user when a new YoutubeChannel is published.
I created a telegram_bot.py in which I created a TelegramBot class.
In this class I have this function:
telegram_bot.py
def __init__(self):
self.updater = Updater(token=telegram_token, use_context=True)
self.dispatcher = self.updater.dispatcher
self.updater.start_polling()
def send_message(self, text_message, context: CallbackContext):
context.bot.send_message(
chat_id="@<<my username>>", text=text_message)
And in the main.py I have a line of code that should send the message usign the aforementioned function, like this:
main.py
from telegram_bot import TelegramBot
tg_bot = TelegramBot()
tg_bot.send_message("New video!")
But, when I run the code above, I get this error:
TypeError: send_message() missing 1 required positional argument: 'context'
But in the send_message definition I already defined the context