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.2

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.2
File Size Uploaded
pyromenu-1.2.tar.gz 3.8 kB Details

Built distribution (wheel)

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

Total release size: 11.9 kB

Release files / pyromenu-1.2.tar.gz

Download URL pyromenu-1.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
231a0d42494d8d5121091c59481d23295cd7924274cffc1c73758ba3cfb7ec48
BLAKE2b-256 checksum
How to use checksums
c27d8080b397e22e667eef45f3fcaa72311e6d80b70a0a1c7f70bf5de01856f1
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/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

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

Download URL pyromenu-1.2-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08341ece3c526940b210a66de517c772117aa8febfa1b1c95ac8d5af3ead6f6b
BLAKE2b-256 checksum
How to use checksums
42b04bb8e8214a3afab44779531b77d8352742d1896feffe4c37606530ccff8b
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/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

Release history Release notifications | RSS feed

2.0

2 release files

1.3

2 release files

This release

1.2 This release

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