Skip to main content

A shell for telethon

Project description

teleshell

Install:

pip install teleshell

Sample usage:

from teleshell import *
from telethon import TelegramClient

client = TelegramClient('bot', api_id, 'api_hash').start(bot_token='token')


async def add_user(event):
    for user in users:
        if user == event.chat_id:
            return None
    users.append(event.chat_id)

shell = ClientShell(client=client, default_first=add_user)
handle = shell.handle
users = []


@handle(text='hi', lower=True, first=False)
async def func(event):
    await event.reply('Hello!')

@handle(text=r'he(l){1,7}o', lower=True, regular=True)
async def func(event):
    await event.reply('Hellllllllo!')


@handle(command='start')
async def func(event):
    await event.reply('Start!')


@handle(command='help', first=add_user)
async def func(event):
    await event.reply('Help!')

client.run_until_disconnected()

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

teleshell-0.0.1.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

teleshell-0.0.1-py3-none-any.whl (13.4 kB view hashes)

Uploaded Python 3

Supported by

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