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.5.tar.gz
(2.7 kB
view hashes)
Built Distribution
teleshell-0.0.5-py3-none-any.whl
(14.7 kB
view hashes)
Close
Hashes for teleshell-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9bda3f586b9781a60a8cc167443438b9de001cd6e2b4191f8fb600ab96a468e |
|
MD5 | 0fba5826c8ff442a1f6a31ceb9c1ad1e |
|
BLAKE2b-256 | 0a8e0aace7d0eee873fcecefc4bcb283f01ab914b64d479a95f5a30cb43eaf1e |