💥 TamTam.py is about performance, so it requires ujson for serialization and deserialization, pydantic for models management, aiohttp for web requests
pip install https://github.com/uwinx/tamtam.py/archive/master.zip
ℹ️ Setting bot-info:
from tamtam import Bot, types, run_async
Bot("put token @PrimeBot gave")
async def func():
info = await types.BotInfoSetter(
name="MyBotsName",
description="smth...",
)
print(info)
run_async(func())
from tamtam import Bot, Dispatcher, types, run_poller
bot = Bot("put token @PrimeBot gave")
dp = Dispatcher(bot)
@dp.message_handler()
async def msg_handler(msg: types.Message):
await msg.reply("Hello!")
run_poller(func())
@dp.bot_started()
async def start_handler(upd: types.BotStarted):
await upd.respond("you started bot")
from tamtam import Bot, Dispatcher, types, run_sever
bot = Bot("token")
dp = Dispatcher(bot)
@dp.bot_started()
async def handler(upd: types.BotStarted):
await upd.respond("Sup!")
run_server()
# better example in repo/examples/
async def sub(url):
if not (await bot.subscribe(url))["success"]:
# something went wrong
...
...
url = "https://my.domain/path" # or use yarl.URL.build
from tamtam import run_async
run_async(sub(url))
@dp.message_handler(MessageFilters.match(r"^.ban \d$"))
async def ban_user_handler(message: types.Message):
...
You can use tamtam.types.attachments::InlineKeyboardAttachment, but ... I find it quite inconvenient to utilize and, that's why we have tamtam.types.attachments::ButtonsArray Think of ButtonsArray as an abstraction from list[list[button]].
from tamtam.types import ButtonsArray, CallbackButton, InlineKeyboardAttachment
array = ButtonsArray()
row, index = array.add_row(1) # pass None for dynamic row
row.add(CallbackButton("text", "payload", "negative"))
row2, index2 = array.add_row(1)
array.delete_row(index2)
# further actions, e.g send message
attachments = (InlineKeyboardAttachment.from_array(array), )
GetJson this bot returns sent message's json (useful for developers or no)
See examples for more.
If your bot using tamtam.py, let me know!
- Try to avoid using webhooks :) For safety, first of all.
- Don't use another library-wrapper for tamtam.py.
- async/await syntax is easy. asyncio does not eat people. Stay modern.