Skip to main content

bafser tgapi

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(db_sess, 12345, False, "Admin", "", "username", "en")
    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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bafser_tgapi-1.10.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

bafser_tgapi-1.10.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file bafser_tgapi-1.10.0.tar.gz.

File metadata

  • Download URL: bafser_tgapi-1.10.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bafser_tgapi-1.10.0.tar.gz
Algorithm Hash digest
SHA256 efde1f01f5d1dcc87c984797fa79587fc41fb8aaa1f6b75774099117beed8f1f
MD5 8b1333783798fb8e4770d340339f92c4
BLAKE2b-256 13a0eba7e19fffdea185c8147fa3b04afaf874f0f726c47626fb6740f6709f54

See more details on using hashes here.

Provenance

The following attestation bundles were made for bafser_tgapi-1.10.0.tar.gz:

Publisher: main.yml on MixelTe/bafser_tgapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bafser_tgapi-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: bafser_tgapi-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bafser_tgapi-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 745ad5a79ca313581b0406ca920627ee89e3156fdbd3ed5b9fca576ef52e8033
MD5 a80511211518e8d1c4d7922eea9c51ea
BLAKE2b-256 a1cdce988be59aa30c2c5c95c75da7527b1cb9f6f7ffc301fbeb69bf9310aa0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for bafser_tgapi-1.10.0-py3-none-any.whl:

Publisher: main.yml on MixelTe/bafser_tgapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.10.0 This release

2 files

1.9.0

2 files

1.8.3

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.1

2 files

1.7.0

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.1

2 files

1.5.0

2 files

1.4.6

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page