Skip to main content

An elegant and scalable framework for Telegram bots, based on Telethon

Project description

Folds

Folds is an elegant and scalable framework for bots, wrapping Telethon library.

  • Minimalistic when you need simple features, powerful when you need complex ones.
  • Flexible app structure with no boilerplate and no imports in the middle of files.
  • Easy support for multi-bot apps.
  • Built with Telegram API without Bot API — I explain it below.

https://pcraft.dev/folds

from folds import Bot, Message, ThisUser

bot = Bot(bot_token, api_id, api_hash)


@bot.added_to_group
async def handle_added():
  return 'Hello!'


@bot.group_commands.help
async def handle_help_command():
  return 'You called for /help?'


@bot.group_commands.hello
async def handle_hello_command(message: Message, user: ThisUser):
  await message.reply('Hmm!')
  await message.reply(f'Hello, {user.first_name}')


bot.run()

Built with Telegram API

Folds is built on top of Telethon, a Telegram API library. This means Folds doesn't use Bot API.

Pros

  • No limitations. Folds doesn't have natural limitations that Bot API has: see the API explanation and the comparison table from the Papercraft Book for details.
  • Reuse code for userbots. When you are familiar with Telethon concepts, you can not only program bots with Folds but also program user accounts. In particular, our Telegram script tool named TGPy is also based on Telethon.

Cons

  • Setting up requires a little extra step.

Should I use it?

The framework is in its early version, and the features will change, so...

For small hobby bots — yes. For big complex projects — also yes, but better come back later! I will appreciate if you show your interest by leaving a star on the repo.

Learn

Here is how to get familiar with Folds:

  • Read these docs, of course. I tried to make them friendly!
  • Read the Telethon docs because Folds bases on Telethon. ChatGPT knows Telethon well, apparently.
  • For specific features, read the Papercraft Book, my book on developing Telegram bots. It includes code examples for Folds.

Getting Started

Head over to Quick Start.

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

folds-0.2.1.tar.gz (103.0 kB view details)

Uploaded Source

Built Distribution

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

folds-0.2.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file folds-0.2.1.tar.gz.

File metadata

  • Download URL: folds-0.2.1.tar.gz
  • Upload date:
  • Size: 103.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for folds-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fc6247fc054db78b87c295257aa5cfe2b396f9422f75e5fa54834d5892014c55
MD5 0ddd0b4f0b8ed5895e8f11410404df00
BLAKE2b-256 458efc7de8adeadb1260de77314e4169ee1f22636932c98dc0fd14bbc7e1a980

See more details on using hashes here.

File details

Details for the file folds-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: folds-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for folds-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db01ff5af41d42f0dea24dec7ae66b46b6e674493e7d7ba40a66e56a367d6e39
MD5 153c734e3d9914d7c398dcf3e281fd1b
BLAKE2b-256 f0b76b58659c0a5d4314cae0e69f0f50e7e4c67a32706b7418efd3877cc10b37

See more details on using hashes here.

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