MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / __init__

Method __init__

camel/bots/telegram_bot.py:37–59  ·  view source on GitHub ↗
(
        self,
        chat_agent: ChatAgent,
        telegram_token: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

35
36 @dependencies_required('telebot')
37 def __init__(
38 self,
39 chat_agent: ChatAgent,
40 telegram_token: Optional[str] = None,
41 ) -> None:
42 self.chat_agent = chat_agent
43
44 if not telegram_token:
45 self.token = os.getenv('TELEGRAM_TOKEN')
46 if not self.token:
47 raise ValueError(
48 "`TELEGRAM_TOKEN` not found in environment variables. "
49 "Get it from t.me/BotFather."
50 )
51 else:
52 self.token = telegram_token
53
54 import telebot # type: ignore[import-untyped]
55
56 self.bot = telebot.TeleBot(token=self.token)
57
58 # Register the message handler within the constructor
59 self.bot.message_handler(func=lambda message: True)(self.on_message)
60
61 def run(self) -> None:
62 r"""Start the Telegram bot."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected