Skip to content

TypeError: Start_Handler.start_message() missing 1 required positional argument: 'message' #1998

@kelogsloops

Description

@kelogsloops

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using?
    latest
  2. What OS are you using?
    win
  3. What version of python are you using?
    3.7
    I would like to encapsulate the functionality as a class, but when I try I get some strange errors. How should I encapsulate them correctly?

`
class Start_Handler(object):

def __init__(self, bot = bot) -> None:
    self.bot = bot

@bot.message_handler(commands = ['start'], content_types = ['text'], chat_types = ['private'])
def start_message(self, message):
    bot.send_photo(
        chat_id = message.from_user.id,
        photo = InputFile("Bot/assest/logo.jpg"),
        caption = f"*🥳 Congratulation, [_{message.from_user.first_name}_](tg://user?id={message.from_user.id}) has become a member of our\.*",
        parse_mode = 'MarkdownV2'
    )

`

Start_Handler(bot=bot).start_message()
TypeError: Start_Handler.start_message() missing 1 required positional argument: 'message'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions