Skip to main content

A shell for telethon

Project description

teleshell

Install:

pip install teleshell

Quick start:

import teleshell
from telethon import TelegramClient, Button


users = []

async def message_first(event):
    users.append(event.chat_id)
    return event.chat_id


async def inline_first(event):
    users.append(event.query.user_id)
    return event.query.user_id

client = TelegramClient('bot', api_id, 'api_hash').start(bot_token='token')
shell = teleshell.ClientShell(client=client, message_first=message_first, inline_first=inline_first)
handle = shell.handle
inline = shell.inline
button = shell.button


@handle(command='start')
async def func(event, first=None):
    await event.reply('Started!')


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


@handle(text=r'he(l)+o', regular=True, lower=True)
async def func(event, first=None):
    await event.reply('Hello!')


@handle(command='buttons')
async def func(event, first=None):
    keyboard = [
        [
            Button.inline("First option", b"1"),
            Button.inline("Second option", b"2")
        ]
    ]

    await event.reply('OK!', buttons=keyboard)


@inline(command='smth', lower=True)
async def func(event, first=None):
    await client.send_message(event.query.user_id, 'Smth to!')


@button(text=b'1')
async def func(event, first=None):
    await event.answer('hello')

client.run_until_disconnected()

Version: 0.0.2

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.6.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

teleshell-0.0.6-py3-none-any.whl (14.8 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