-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* custom parser for types * avoid error for manually parsing * force parse * fix parsing property/bound methods * customize types example
- Loading branch information
Showing
3 changed files
with
1,732 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
from tgram import TgBot, filters | ||
from tgram.types import Message | ||
|
||
bot = TgBot("API_TOKEN_HERE") | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
class CustomizedMessage(Message): | ||
@property | ||
def hello(self) -> str: | ||
return f"Hello {self.from_user.full_name} !" | ||
|
||
|
||
bot.customize(Message, CustomizedMessage) | ||
|
||
|
||
@bot.on_message(filters.private & filters.command("start")) | ||
async def say_hello(_, m: CustomizedMessage) -> CustomizedMessage: | ||
return await m.reply_text(m.hello) | ||
|
||
|
||
bot.run_for_updates() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.