Skip to main content

A telegram SDK offering clean and simple route decorators.

Project description

Note: This is not the official pyTelegramBotAPI library. This is a lightweight alternative with similar syntax and functionality. If you accidentally install this package instead of pyTelegramBotAPI, don't worry. your basic bot code will still work seamlessly. This package maintains compatibility with common pyTelegramBotAPI patterns while providing additional simplicity and ease of use.

Example Setup

from sounava import telegram

bot = telegram("YOUR_BOT_TOKEN")

@bot.command('/start')
def start_command(update, bot):
    bot.reply(update, "Hello World!.")

@bot.message
def echo(update, bot):
    bot.reply(update, f"You said: {update['message']['text']}")

bot.start()
p("Name:", get("name")),
p("Age:", get("age")),

if_(
    gt(get("age"), 18),
    p(get("name"), "is an adult"),
    else_=p(get("name"), "is a minor")
)

)

program.run()


**Output:**
```sh
Name: Alice
Age: 25
Alice is an adult

Core Components

Basic Structure:
· src(*nodes) - Main program container
· var(name, value) - Variable declaration
· p(*values) - Print statement
· get(name) - Variable reference

Control Flow:
· if_(condition, then_branch, else_branch) - If statement
· for_(item, iterable, body) - For loop
· while_(condition, body) - While loop

Functions:
· function(name, params, *body) - Function definition
· call(name, args) - Function call
· return_(value) - Return statement

Data Structures:
· list_(*items) - List literal
· dict_(**items) - Dictionary literal

Operations:
· add(a, b), subtract(a, b), multiply(a, b), divide(a, b)
· eq(a, b), neq(a, b), gt(a, b), lt(a, b)
· and_(a, b), or_(a, b), not_(a)

Advanced Examples

Function with Loop

from starexx import *

program = src(
    function(
        "calculate_sum",
        ["numbers"],
        var("total", 0),
        for_("num", get("numbers"), src(
            set_("total", add(get("total"), get("num")))
        )),
        return_(get("total"))
    ),
    
    var("scores", list_(85, 92, 78, 96)),
    var("total_score", call("calculate_sum", [get("scores")])),
    p("Scores:", get("scores")),
    p("Total:", get("total_score"))
)

program.run()

List Operations

from starexx import *

program = src(
    var("fruits", list_("apple", "banana", "orange")),
    p("Fruits:", get("fruits")),
    p("First fruit:", call("fruits.__getitem__", [0])),
    
    # Add a new fruit
    call("fruits.append", ["grape"]),
    p("Updated fruits:", get("fruits")),
    
    # List length
    p("Number of fruits:", len_(get("fruits")))
)

program.run()

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

sounava-0.0.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

sounava-0.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file sounava-0.0.1.tar.gz.

File metadata

  • Download URL: sounava-0.0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sounava-0.0.1.tar.gz
Algorithm Hash digest
SHA256 906223a75fc8cff8bb8a1e4c60031fa8f7489e4a57bfdbb33f6c2c7a4d5b08d3
MD5 0eb2377e9955f18a7668a368915ad56b
BLAKE2b-256 802173170d9e79c6997f2f6e16cd265bbfd39f5decd096bf4ea779128226dae8

See more details on using hashes here.

File details

Details for the file sounava-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sounava-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sounava-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84939f6bf3f628e4f15e32ece58f39bb5ca13926369b59780db4eb36f743830f
MD5 42f0abca3a4f7228f9aeed7e5f06b4d8
BLAKE2b-256 941a27844070fd5a0ba79273b4530908a5989787766392cfc5e4ed219467749e

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