Skip to main content

Pyromenu Build Status

Pyromenu is an easy-to-extend object-oriented library for building keyboard menus for telegram bots on the Pyrogram.

Usage example

from pyrogram import Client, Filters, ReplyKeyboardRemove
from pyromenu import KButton, KRow, KMenu


app = Client("app")
# it's menu declaration style
menu = KMenu(
  KRow(
    KButton("English"), KButton("Russian"), KButton("Portugues")
  ),
  KRow(
    KButton("exit")
  )
)


@app.on_message(Filters.command("start"))
def send_keyboard(clt, msg):
  msg.reply("Hi / Привет / Oi", reply_markup=menu.keyboard())

# use KButton update_filter method for creating Filter for Handlers
@app.on_message(KButon("exit").update_filter())
def remove_keyboard(clt, msg):
  msg.reply("Bye / Пока / Adeus", reply_markup=ReplyKeyboardRemove())

How it works?

Pyromenu contains 3 built-in classes KMenu, KRow, KButton, which are implementations of Menu, Row and Button interfaces. Each interface contains a minimal set of methods for implementing keyboard menu creation.

  • Button declares 2 methods keyboard_button and update_filter, where first return Pyrogram KeyboardButton object, second return Pyromenu Filter object.
  • Row declares only one method - keyboard_row, which return list of KeyboardButton objects.
  • Menu declares 2 methods keyboard and one_time_keyboard, which returns Pyrogram ReplyKeyboardMarkup, but second return it with the one_time_keyboard attribute turned on.

How to expand?

All built-in classes have minimal dependency on others. All you need to do is implement interface. For example if you need to create button, which send location request you can create that:

from pyrogram import KeyboardButton, Filters
from pyromenu.interfaces import Button


class LocationButton(Button):
  def __init__(self, text):
    self._text = text

  def keyboard_button(self):
    return KeyboardButton(self._text, request_location=True)

  def update_filter(self):
    return Filters.create(
            name=f"{self._text}ButtonFilter",
            func=lambda flt, msg: flt.btn_txt == msg.text,
            btn_txt=self._text,
        )

or that:

from pyrogram import KeyboardButton
from pyromenu import KButton

class LocationButton(KButton):
  def keyboard_button(self):
    return KeyboardButton(self._text, request_location=True)

and it's will be works well with KRow class, because it wait a Button-compatible interface.

Installing

pip3 install pyromenu

Metadata

Release files for pyromenu 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyromenu 1.3
File Size Uploaded
pyromenu-1.3.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyromenu 1.3
File Interpreter ABI Platform
pyromenu-1.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / pyromenu-1.3.tar.gz

Download URL pyromenu-1.3.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d72888d2cba2aee54c2a0eb3ee2ff22999d3370ae14d401cb89be3648c129d22
BLAKE2b-256 checksum
How to use checksums
7058a29678f2afaa699a4e1b5870ec2b2460a5a5fe0d4d2eae666ea9d34132be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release files / pyromenu-1.3-py3-none-any.whl

Download URL pyromenu-1.3-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9f886bd087e1eb9c410a3e0d520e6c2acc64450e6e5dd8686530060532f42f4
BLAKE2b-256 checksum
How to use checksums
3079be97b22d6411c9f63dbe89b45122a381ef4df7731a7b78b90825327f9c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release history Release notifications | RSS feed

2.0

2 release files

This release

1.3 This release

2 release files

1.2

2 release files

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page