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)
Built Distribution
teleshell-0.0.6-py3-none-any.whl
(14.8 kB
view hashes)
Close
Hashes for teleshell-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9e4002f4a51c5cab95c1b3719d427aac8a347edc2d049497117c4bf349c103a |
|
MD5 | 91ab193d8a23eeef0df285487fa774d9 |
|
BLAKE2b-256 | 86474ac073d328bddf1352e4907c138eaf3844b64bd92d64cdc4db9ce1cbab44 |