Skip to main content

bafser tgapi

Requires Python 3.10+ and bafser 2.12.2+ (2.12.x).

tests

python -m pip install -e .
python -m unittest discover -s test -v

usage

  • init project: bafser init_project
  • set webhook: bafser configure_webhook set
  • delete webhook: bafser configure_webhook delete
  • get sticker file_id: bafser stickers

main.py

import sys

import bafser_tgapi as tgapi
from bafser import AppConfig, create_app

from bot.bot import Bot
from scripts.init_db import init_db

app, run = create_app(__name__, AppConfig(DEV_MODE="dev" in sys.argv))
tgapi.setup(botCls=Bot, app=app)

DEVSERVER = "devServer" in sys.argv
if DEVSERVER:
    tgapi.set_webhook()
run(DEVSERVER, init_db)

if not DEVSERVER:
    if __name__ == "__main__":
        tgapi.run_long_polling()
    else:
        tgapi.set_webhook()

init_db.py

from bafser import AppConfig
from sqlalchemy.orm import Session

from data.user import Roles, User


def init_db(db_sess: Session, config: AppConfig):
    u = User.new(12345, False, "Admin", "", "username", "en", db_sess=db_sess)
    u.add_role(u, Roles.admin)

    db_sess.commit()

data.user.py

from bafser_tgapi import TgUserBase

from data import Roles


class User(TgUserBase):
    _default_role = Roles.user

data.msg.py

from bafser_tgapi import MsgBase

from data import Tables


class Msg(MsgBase):
    __tablename__ = Tables.Msg

bot.py

import bafser_tgapi as tgapi

from data.user import User


class Bot(tgapi.BotWithDB[User]):
    _userCls = User

call other method

import json

import bafser_tgapi as tgapi

ok, r = tgapi.call("getStickerSet", {
    "name": "AnimatedEmojies",
})
with open("r.json", "w") as f:
    json.dump(r, f)

Metadata

Release files for bafser-tgapi 1.12.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 bafser-tgapi 1.12.1
File Size Uploaded
bafser_tgapi-1.12.1.tar.gz 23.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bafser-tgapi 1.12.1
File Interpreter ABI Platform
bafser_tgapi-1.12.1-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / bafser_tgapi-1.12.1.tar.gz

Download URL bafser_tgapi-1.12.1.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9f9ca128d3ef61dbc5fd45425509a3294f6474b80e3ec385ac5e17a87f503e4d
BLAKE2b-256 checksum
How to use checksums
bc7ad8a3fb18176466003591859264e4b05237c50ebf6f12a91a995eaa4cdacb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / bafser_tgapi-1.12.1-py3-none-any.whl

Download URL bafser_tgapi-1.12.1-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9cc5f1996c5bdb7efcd18cdfc0d8a3131438889f52db549a705fd4b797a9775
BLAKE2b-256 checksum
How to use checksums
982cfd6291d4a12df0ad1b1e137b1a9f5a9193b040157e6447044b19e5f2783e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.12.1 This release

2 release files

1.12.0

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

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