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.
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.1.0.tar.gz (43.2 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.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: folds-0.1.0.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for folds-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2ddad551c9c41f9352fd16ac972df310f76d628181836165d70263fbcf2bf35
MD5 549a5feb3a5049c703a4452cdec18c83
BLAKE2b-256 77d0e44151599ad9937d7e5be51e1571d2768cd636b01192b6b6a77779055f19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: folds-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for folds-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a58ef91ccfb4e14c30b0b7d31900694177cf9b2ddbadf999c9a025034b297066
MD5 977c0b6c747c41c22b87b1a01093989e
BLAKE2b-256 2583afee87a58bafc9707bb0b749378ac9311821b327194ee123e689a948eee4

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