Skip to content

tm-a-t/folds

Repository files navigation

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.

About

The most elegant Telegram bot framework for Python. Works without Bot API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages