Skip to main content

A powerful pagination library for Pyrogram bots

Project description

Helpo 📚

A powerful and flexible pagination library for Pyrogram bots that automatically handles help commands and module organization.

Python Pyrogram License

Features ✨

  • 🔄 Automatic module discovery and help text organization
  • 📱 Beautiful paginated help menus with inline buttons
  • 🎯 Support for both command-based and button-based help
  • 🎨 Customizable button layouts and texts
  • 🔌 Easy integration with existing Pyrogram bots
  • 📝 Support for rich media in help messages (photos, videos)
  • 🔗 Deep linking support for direct access to help menus

Installation 🚀

pip install pyrohelpo

Usage ⚙️

Initialize the Helpo instance

from Helpo import Helpo

custom_texts = {
    "help_menu_title": "**🛠 Custom Help Menu**",
    "help_menu_intro": "Available modules ({count}):\n{modules}\n\nTap on a module to explore.",
    "module_help_title": "**🔍 Details for {module_name} Module**",
    "module_help_intro": "Description:\n{help_text}",
    "no_modules_loaded": "⚠️ No modules available at the moment.",
    "back_button": "◀️ Go Back",
    "prev_button": "⬅️ Previous Page",
    "next_button": "➡️ Next Page",
    "support_button": "💬 Contact Support",
    "support_url": "https://t.me/YourSupportBot",
}

pagination = Helpo(
    client=bot,
    modules_path="fwd/plugins",
    buttons_per_page=9,
    texts=custom_texts,
    help_var="HELP",
    module_var="MODULE",
    video="" # pass video path/url 
    photo="" # pass photo path/url
    # only one type of media support at one time pass photo else video to use them in /help command 
    parse_mode=ParseMode.HTML # pass if want to change parse mode Default to markdown         
    disable_web_page_preview=False # Deafuults to True
)

Set up help and module for each Python file in the modules path

MODULE = "HELPO"

HELP = "GO GOA GONE"  # You can use docstrings too

Using a custom class

from pyrogram import Client
from Helpo import Helpo

class Bot(Client):
    def __init__(self):
        super().__init__(
            "Hoshi-new",
            api_id=API_ID,
            api_hash=API_HASH,
            bot_token=TOKEN,
            plugins=dict(root="shivu"),
        )
        self.helpo = Helpo(
            client=self,
            modules_path="shivu/modules",
            buttons_per_page=6,
            texts=custom_texts,
        )

    async def start(self):
        await super().start()
        print("Pyro Bot Started")
        print(f"Helpo Initialized with Modules: {', '.join(self.helpo.modules.keys())}")

    async def stop(self):
        await super().stop()
        print("Pyro Bot Stopped")

Deep linking support

@bot.on_message(filters.command("start"))
async def start_command(client, message):
    if len(message.text.split()) > 1:
        name = message.text.split(None, 1)[1]
        if name.startswith("help"):
            await bot.show_help_menu(message.chat.id, page=1)

Adding a help button anywhere without callback query

from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from . import pagination  # Import your Helpo instance

@bot.on_message(filters.command("start"))
async def start_command(client, message):
    keyboard = InlineKeyboardMarkup([
        [InlineKeyboardButton("Help", callback_data="global_help")]
    ])
    await message.reply("Welcome! Click the button below for help.", reply_markup=keyboard)

Customization Options 🎨

Helpo offers various customization options to tailor the help menu to your bot's needs:

  • buttons_per_page: Set the number of buttons displayed per page (default: 6)
  • texts: Customize all text messages and button labels
  • help_var and module_var: Set custom variable names for help text and module names
  • photo and video: Add rich media to your help messages
  • parse_mode: Set the parse mode for help messages (default: ParseMode.MARKDOWN)
  • disable_web_page_preview: Enable or disable web page previews in help messages

Image Gallery

Help menu using video

Help menu using video Description: This menu displays video tutorials to help users.

Help menu using only text

Help menu using only text Description: This menu uses text-based instructions for simplicity.

Help menu using photo

Help menu using photo Description: This menu uses images to visually assist users.

Help menu of a module

Help menu of a module Description: This menu shows a module-specific help interface.

Methods and Attributes 📚

Helpo Class

Attributes:

  • client: The Pyrogram Client instance
  • modules_path: Path to the modules directory
  • buttons_per_page: Number of buttons per page in the help menu
  • help_var: Variable name for help text in modules
  • module_var: Variable name for module name in modules
  • photo: Optional photo to be used in help messages
  • video: Optional video to be used in help messages
  • parse_mode: Parse mode for help messages
  • disable_web_page_preview: Whether to disable web page previews in help messages
  • texts: Dictionary of customizable text strings

Error Handling

Helpo includes error handling for various scenarios:

  • Invalid module files
  • Missing required attributes in modules
  • Failed module loading
  • Message sending failures

Contributors 👥

License 📄

This project is licensed under the MIT License - see the LICENSE file for details.

Support 🤝

If you encounter any issues or have questions, please open an issue on the GitHub repository or join our support chat.

Acknowledgements 🙏

  • Pyrogram - The awesome MTProto library for Python
  • All contributors who have helped this project grow

Made with ❤️ by the Helpo team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrohelpo-2.3.4.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrohelpo-2.3.4-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pyrohelpo-2.3.4.tar.gz.

File metadata

  • Download URL: pyrohelpo-2.3.4.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyrohelpo-2.3.4.tar.gz
Algorithm Hash digest
SHA256 c2e877740e26e20122da95eaf4ab37c2fb57fe8c72bc242aa55b3cabe51bbf5b
MD5 1ebbaaee25d063272324a1271d80e83e
BLAKE2b-256 66c336dd877f8845efd3a85d0c4381387d4b3202b72589cb90edbdb708c47e92

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrohelpo-2.3.4.tar.gz:

Publisher: publish.yml on Vishal-1756/pyrohelpo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrohelpo-2.3.4-py3-none-any.whl.

File metadata

  • Download URL: pyrohelpo-2.3.4-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyrohelpo-2.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4212a3d09729d84c623450ba0f47d8fbf5821c9bdb4c4e89210603d573c7f601
MD5 3da167f30500b7f1f0953f38abab0378
BLAKE2b-256 d70e7cec6d15ba82ded724e33f5715257bb570b25d0a69740324f6ae39f9e05b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrohelpo-2.3.4-py3-none-any.whl:

Publisher: publish.yml on Vishal-1756/pyrohelpo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page