Skip to main content

WETG v7 Super Weox โ€” One-File Telegram Bot Engine. Write Telegram bots in a simple scripting language.

Project description

๐Ÿ”ฅ WETG v7 โ€” Super Weox

One-File Telegram Bot Engine โ€” Write Telegram bots in a simple scripting language. No boilerplate. No classes. Just write.

pip install wetg

โšก Quick Start

# Create a bot from template
wetg new mybot.wetg

# Edit it, add your token from @BotFather
nano mybot.wetg

# Run it
wetg run mybot.wetg

That's it.


๐Ÿ“ Language

Hello World bot

bot "YOUR_TOKEN_HERE"

on /start
    send "Hello, {user.name}! ๐Ÿ‘‹"

on /ping
    send "๐Ÿ“ Pong!"

Full feature example

bot "YOUR_TOKEN_HERE"

set welcome=Hello!

# โ”€โ”€ Commands โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

on /start
    send "๐Ÿ‘‹ Hi {user.name}! {welcome}"

on /help
    send "/start\n/ping\n/echo\n/about"

on /ping
    send "๐Ÿ“ Pong!"

on /about
    button = ["Our Website", "https://example.com"]
    send "Powered by WETG v7 Super Weox." with button

on /echo
    ask "What should I echo?"

# โ”€โ”€ User messages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

on usermsg
    if {usermsg} == "hi"
        send "Hey! ๐Ÿ‘‹"
    elif {usermsg} == "bye"
        send "See ya! ๐Ÿ‘‹"
    else
        send "You said: {usermsg}"

# โ”€โ”€ Functions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

function welcome_user
    send "Welcome, {user.name}!"
    send "Your ID: {user.id}"

๐Ÿ“– Language Reference

Token

bot "YOUR_TOKEN"

Or use config.txt (recommended โ€” don't commit tokens to git):

TOKEN=YOUR_TOKEN

Sending messages

Syntax Description
send "text" Plain message
send "{user.name}" With variable interpolation
send "**bold**" with markdown Markdown formatting
send "<b>bold</b>" with html HTML formatting
send "photo.jpg" with image Local image file
send "https://..." with image Image from URL
button = ["Label", "url"] then send "text" with button Inline button

Variables

Variable Value
{user.name} User's first name
{user.id} User's Telegram ID
{user.username} User's @username
{bot.name} Bot display name
{bot.username} Bot @username
{usermsg} Last message text from user

Control flow

if {usermsg} == "yes"
    send "You said yes!"
elif {usermsg} == "no"
    send "You said no."
else
    send "You said something else."

Loops

loop 5 times
    send "Looping!"
stop

Ask / input

on /form
    ask "What's your name?"

on usermsg
    send "Nice to meet you, {usermsg}!"

Functions

function greet
    send "Hi {user.name}!"

on /start
    call greet

Variables (set)

set counter=0

on /start
    set counter=1
    send "Counter is {counter}"

Imports

import random

on /roll
    send "๐ŸŽฒ {random.randint(1, 6)}"

๐Ÿ Python API

from wetg_superweox import Wetg
import asyncio

code = """
bot "YOUR_TOKEN"

on /start
    send "Hello from Python API!"
"""

bot = Wetg(code)
bot.parse()
asyncio.run(bot.run())

Or use the helper:

from wetg_superweox import run_file

run_file("mybot.wetg")

๐Ÿ›  CLI

wetg run <file.wetg>     Run a bot
wetg new <file.wetg>     Create bot from template
wetg check <file.wetg>   Validate .wetg file
wetg version             Show version
wetg help                Show help

Shortcuts:

wetg mybot.wetg           # same as: wetg run mybot.wetg
python -m wetg_superweox run mybot.wetg

๐Ÿ”’ Tips

  • Store tokens in config.txt, not in .wetg files
  • Add to .gitignore:
    config.txt
    .env
    

๐Ÿ“œ License

MIT

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

wetg-7.1.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

wetg-7.1.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file wetg-7.1.1.tar.gz.

File metadata

  • Download URL: wetg-7.1.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for wetg-7.1.1.tar.gz
Algorithm Hash digest
SHA256 730e118d3585df95a9c8b9223bfa44cac48e8c2e1b93a638a92723dbabc72c36
MD5 09fc6ff4aa0981a1606d85e21ac4e192
BLAKE2b-256 8fa0ac9805956f4428a099b7399c6fa4372dc4646bab8b1f298a3f86ba647eb7

See more details on using hashes here.

File details

Details for the file wetg-7.1.1-py3-none-any.whl.

File metadata

  • Download URL: wetg-7.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for wetg-7.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8401ec618cdff33d57ab08c203b2c30233a71b974923b570c5a4b2b85d87f57b
MD5 0e1d0e7c4aaf10c2e06bfcbd4974b390
BLAKE2b-256 04c219bacfa774c18702b8c3a30e0f203e8aa14c3a6f6f4443d51baab1a37f0c

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