User access manager for async pyTelegramBotAPI
Project description
PyTelegramBotAPI_Users
User access manager for pyTelegramBotAPI. For now async only.
Features
- Send access requests to admin
- Send a message to the administrator upon receipt of a new request
- Manage requests and users
- Store additional attributes for each user separately
Installation
- Installation from source (requires git):
$ git clone https://github.com/theGENreel/PyTelegramBotAPI_Users.git
$ cd PyTelegramBotAPI_Users
$ python setup.py install
or:
$ pip install git+https://github.com/theGENreel/PyTelegramBotAPI_Users.git
Quick start
import asyncio
from telebot.async_telebot import AsyncTeleBot
from telebot_users.async_users import AsyncTeleBotUsers
async def main():
bot = AsyncTeleBot(TOKEN)
bot_users = AsyncTeleBotUsers(bot, ADMIN_CHATID)
await bot_users.init()
await bot.polling()
asyncio.run(main())
Usage
Create an instance of AsyncTeleBotUsers class. Pass a AsyncTeleBot instance, admin chat_id and optionaly path to folder where to store requests.json and users.json.
bot_users = AsyncTeleBotUsers(bot, ADMIN_CHATID, PATH_TO_FILES)
Await bot_users.init() before bot.polling().
await bot_users.init()
await bot.polling()
In message handlers use bot_users.users to check if user have access to bot.
@bot.message_handler(commands=['work'])
async def work(message):
if message.chat.id in bot_users.users:
# Do some work
Project details
Release history Release notifications | RSS feed
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 PyTelegramBotApi_Users-1.0.tar.gz.
File metadata
- Download URL: PyTelegramBotApi_Users-1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e56a74acb9b4e6b7ac85e8c25eb0bd46217bf19c88ff04d7d774ab35a2757157
|
|
| MD5 |
11f12e16f9b7d2dca4c8189332097655
|
|
| BLAKE2b-256 |
4e6135f15a561084d50596dd62abba08a562cd10b2df7739a4d5c2b0e6d301ca
|
File details
Details for the file PyTelegramBotApi_Users-1.0-py3-none-any.whl.
File metadata
- Download URL: PyTelegramBotApi_Users-1.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9edb67396ab3f43cb928fb3dc24cec211480ce0256eb277095da871b5ab012ce
|
|
| MD5 |
832256ba6307d5d3fd669723ee483723
|
|
| BLAKE2b-256 |
94283a51a54c30a067b32f59660f0e916fe80be24bcedfcd645f24ce7ac06d69
|