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
wetg creator Show Creator Info
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.wetgfiles - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wetg-7.1.2.tar.gz.
File metadata
- Download URL: wetg-7.1.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f154082c496cd15555b6f46b7856403e348d972ea42aff6d45d06ebb5fe5dc7
|
|
| MD5 |
5a6c2b3130c5bb315bca75c1b81aa192
|
|
| BLAKE2b-256 |
4e9c023c12255a140ac287aed763e11a84c27ac55025a46e2145f7d53f2dbeb4
|
File details
Details for the file wetg-7.1.2-py3-none-any.whl.
File metadata
- Download URL: wetg-7.1.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11bf78cd3498658d771fe9e229d90585c92267d09a521d0035951da52db3299e
|
|
| MD5 |
16abfd3ee8dd8a96196c557cad531616
|
|
| BLAKE2b-256 |
f8999686d7af4641d9731d31cc4e9b20b279e08cf641e176891deee705033fb2
|