Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
altlinux-packages-bot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Unitsaev
altlinux-packages-bot
Commits
182266db
Verified
Commit
182266db
authored
Jul 20, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin: add admins commands
parent
d663ab0b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
0 deletions
+50
-0
func.py
src/database/func.py
+5
-0
admin.py
src/handlers/admin.py
+36
-0
__init__.py
src/rules/__init__.py
+1
-0
bot_admin.py
src/rules/bot_admin.py
+8
-0
No files found.
src/database/func.py
View file @
182266db
...
...
@@ -23,6 +23,11 @@ class UserMethod:
"""получение записи пользователя"""
user
:
User
|
None
=
User
.
get_or_none
(
User
.
user_id
==
user_id
)
return
user
@classmethod
def
get_all
(
cls
):
"""Получение записей всех пользователей"""
return
[
user
for
user
in
User
.
select
()]
@classmethod
def
delete
(
cls
,
user_id
:
int
):
...
...
src/handlers/admin.py
0 → 100644
View file @
182266db
from
telegrinder
import
Dispatch
,
Message
from
telegrinder.rules
import
Command
,
Argument
from
altrepo
import
altrepo
from
database.func
import
DB
from
rules
import
BotAdmin
from
config
import
tg_api
dp
=
Dispatch
()
dp
.
message
.
auto_rules
=
BotAdmin
()
@dp.message
(
Command
(
"altrepo_users"
))
async
def
alrtrepo_users
(
m
:
Message
):
users_data
=
DB
.
user
.
get_all
()
user_message
=
""
for
user
in
users_data
:
user_message
+=
f
"{user.user_id} | {user.maintainer} | {user.default_branch}
\n
"
await
m
.
answer
(
user_message
)
@dp.message
(
Command
(
"altrepo_user"
,
Argument
(
"user_id"
)))
async
def
alrtrepo_users
(
m
:
Message
,
user_id
:
int
):
if
not
user_id
:
return
db_user
=
DB
.
user
.
get
(
user_id
)
user
=
(
await
tg_api
.
get_chat
(
chat_id
=
user_id
))
.
unwrap
()
username
=
user
.
username
.
unwrap_or_none
()
await
m
.
answer
(
f
"{user.first_name.unwrap()} {user.last_name.unwrap()}"
f
" (@{username})
\n
"
if
username
else
"
\n
"
f
"Сопровождающий: {db_user.maintainer}
\n
"
f
"Репозиторий: {db_user.default_branch}
\n
"
)
src/rules/__init__.py
0 → 100644
View file @
182266db
from
.bot_admin
import
BotAdmin
src/rules/bot_admin.py
0 → 100644
View file @
182266db
from
telegrinder
import
Message
from
telegrinder.bot.rules.abc
import
ABCRule
from
config
import
config
class
BotAdmin
(
ABCRule
):
async
def
check
(
self
,
m
:
Message
)
->
bool
:
return
m
.
from_user
.
id
in
config
.
admins
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment