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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

teleshell-0.0.6-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file teleshell-0.0.6.tar.gz.

File metadata

  • Download URL: teleshell-0.0.6.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6

File hashes

Hashes for teleshell-0.0.6.tar.gz
Algorithm Hash digest
SHA256 51e0d1b6166af7e6cfcaedea3f75267820a740c6bb4052979991a99db46522e4
MD5 4e133d60a54e329bf2c0d90ccbe9f947
BLAKE2b-256 ca2ab960dab59ae27b5f1c55247f1694a0307819db5691e5f823eb08419e4939

See more details on using hashes here.

File details

Details for the file teleshell-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: teleshell-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6

File hashes

Hashes for teleshell-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b9e4002f4a51c5cab95c1b3719d427aac8a347edc2d049497117c4bf349c103a
MD5 91ab193d8a23eeef0df285487fa774d9
BLAKE2b-256 86474ac073d328bddf1352e4907c138eaf3844b64bd92d64cdc4db9ce1cbab44

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