diff --git a/examples/smart_plugins/main.py b/examples/smart_plugins/main.py new file mode 100644 index 0000000..366ef3b --- /dev/null +++ b/examples/smart_plugins/main.py @@ -0,0 +1,8 @@ +import logging +from tgram import TgBot + +logging.basicConfig(level=logging.DEBUG) + +bot = TgBot("API_TOKEN_HERE", parse_mode="Markdown", plugins="./plugins") + +bot.run_for_updates() diff --git a/examples/smart_plugins/plugins/callback.py b/examples/smart_plugins/plugins/callback.py new file mode 100644 index 0000000..aedd268 --- /dev/null +++ b/examples/smart_plugins/plugins/callback.py @@ -0,0 +1,7 @@ +from tgram import TgBot, filters +from tgram.types import CallbackQuery + + +@TgBot.on_callback_query(filters.regex("^fine$")) +def callback(bot: TgBot, query: CallbackQuery) -> bool: + return query.answer("Good to know!", show_alert=True) diff --git a/examples/smart_plugins/plugins/start.py b/examples/smart_plugins/plugins/start.py new file mode 100644 index 0000000..02672b7 --- /dev/null +++ b/examples/smart_plugins/plugins/start.py @@ -0,0 +1,13 @@ +from tgram import TgBot, filters + +from tgram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton + + +@TgBot.on_message(filters.command("start") & filters.private) +async def on_start_message(bot: TgBot, m: Message) -> Message: + return await m.reply_text( + f"Hi {m.from_user.mention}!, How are you today?", + reply_markup=InlineKeyboardMarkup( + [[InlineKeyboardButton("I'm fine", callback_data="fine")]] + ), + )