Skip to main content

bafser tg api

Project description

bafser tgapi

usage

init project: bafser init_project set webhook: bafser configure_webhook set delete webhook: bafser configure_webhook delete

main.py

import sys

from bafser import AppConfig, create_app
import bafser_tgapi as tgapi

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(
    config_path="config_dev.txt" if __name__ == "__main__" else "config.txt",
    botCls=Bot,
    import_folder="bot",
    app=app,
)

run(False, init_db)

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._roles import Roles


class User(TgUserBase):
    _default_role = Roles.user

data.msg.py

from bafser_tgapi import MsgBase

from data._tables 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

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

bafser_tgapi-1.1.0.tar.gz (11.8 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.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bafser_tgapi-1.1.0.tar.gz
  • Upload date:
  • Size: 11.8 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.1.0.tar.gz
Algorithm Hash digest
SHA256 bd275b03f3471f60dfa269e5a6fb42021aae9070fcc7a2bdd7796a622bb60b12
MD5 1cc089ab11877b2be47e91cddf5312bc
BLAKE2b-256 82c58352f4e4adee68d8eaf09acc4d0e4f06fc3006e317f4b10d1aaddccd44b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bafser_tgapi-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: bafser_tgapi-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d21ffdd12a321021c6c3e0706fc2dd1bc96cbf0b46a5210964428872cfa00add
MD5 0e35fc107995c0e8320ac7e5f2347aac
BLAKE2b-256 c44a5cc704063126155422e15218c29e42597a6e8564b894b8c5bf23344b0477

See more details on using hashes here.

Provenance

The following attestation bundles were made for bafser_tgapi-1.1.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.

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