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.0.tar.gz (102.9 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.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: folds-0.2.0.tar.gz
  • Upload date:
  • Size: 102.9 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.0.tar.gz
Algorithm Hash digest
SHA256 8618c48996b3e2114f06b241bc1d5eb543ea5964eefc17e8bce140c1079cefb3
MD5 cec080c8bfd99264a3ab409d75b9fd64
BLAKE2b-256 317f757c51c07cfacc0e5760e8692b32d78da47c8e9764c911859311360b0c9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: folds-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fa7cff7546f4e36a64c9ba6828d983e7c1e3fbcbc6e8c9ee79269d0f2ed23fe
MD5 bb4b5a8107ee2f74dc763de383d554d7
BLAKE2b-256 90cab8c5e05a5ed856b3eeb6d64191c2fa025e5cc26332f0e8932ec93231fd4f

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