Skip to main content

Televiewshka

Note: as for now, this is neither stable nor working code. Being Created in ... purposes it is a subject for further updates and improvements

viewshka - Russian noun: informal of eng. "view", obtained by adding a diminutive suffix "shka"

Televiewshka allows you develop UI & logic for telegram bots with class based views. In views you can define its content and how user actions and replies must be handled on it. When all stuff related particular step in user flow is held in one class, you can clearly see relationship between components

Televiewshka supposed to be developed in such a manner to be compatible with a bunch of libs and frameworks for telegram bot api widely used by community

I guess I should write few adaptors for this purpose someday

(Supposed) Example

from telebot import TeleBot
from televiewshka import KeyboardView, \
    KeyboardLayout, Button, adaptors, handler, render

# create adaptor for your lib/framework
bot = TeleBot("super-secret")
bot = adaptors.create_adaptor(bot)


# specify views
class FirstView(KeyboardView):
    @bot.action_handler(action="next")
    def go_next(self, query: Query):
        return render("NextView", inplace=True, param=42)

    @staticmethod
    def render():
        return KeyboardLayout(
            keyboard = (
                Button("Go next", on_click="next"),
            ))


class NextView(KeyboardView):
    @bot.action_handler()
    def back(self, query: Query):
        return render(FirstView, inplace=True)

    @staticmethod
    def render(param: int):
        return KeyboardLayout(
            text=f"Passed param: {param}",
            keyboard = (
                Button("Go back", on_click="back"),
            ))

# run the bot
bot.start()

Some details explained

Views

something that can be rendered to user and than handle user actions on itselves actions are dispatched to appropriate view' and method in accordance with user state (e.g. current_scene flag) which is set when the view is rendered

Dispatch

messages are being dispatched according to user' state state = current view callback data or message = view method

User state

pass

Release files for televiewshka 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for televiewshka 0.0.1
File Size Uploaded
televiewshka-0.0.1.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for televiewshka 0.0.1
File Interpreter ABI Platform
televiewshka-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / televiewshka-0.0.1.tar.gz

Download URL televiewshka-0.0.1.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eb5a5754215036b178db50be63346db3ecc60ba28ccad33efc082cb4736e3e70
BLAKE2b-256 checksum
How to use checksums
e3c245a75c3a81e0dbe2e31e1cd74797caa92728931dda3d00a53eabc1fa2894
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / televiewshka-0.0.1-py3-none-any.whl

Download URL televiewshka-0.0.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bf0885c168ba52cbe64540bc447faf885853b9a3a1879e1cae223ced00baf6b
BLAKE2b-256 checksum
How to use checksums
7d26695c4c3b99041067ee54488f83ac1238894ef821a5f51c7d13353bb000e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page