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.0

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.0
File Size Uploaded
bafser_tgapi-1.12.0.tar.gz 22.6 kB Details

Built distribution (wheel)

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

Total release size: 45.6 kB

Release files / bafser_tgapi-1.12.0.tar.gz

Download URL bafser_tgapi-1.12.0.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2afbf3c72aa2cc16052f6aee79dbf81f2a1229c5d3dc35c4b6f7a8e6403ab9f3
BLAKE2b-256 checksum
How to use checksums
6c02a3ab66627d59b64db2a609240d3a21918bcd9ca397026b463c29f59d23b2
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.0-py3-none-any.whl

Download URL bafser_tgapi-1.12.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0c3574a6a5d79314372b881ef4092d8791a90a27fc39c08171ab64138918564
BLAKE2b-256 checksum
How to use checksums
122248186ea34e490c6ce43e6e5f03e82d096f9f7154ae3f7eccee5550abfe2b
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

1.12.1

2 release files

This release

1.12.0 This release

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