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
0f074af2
Verified
Commit
0f074af2
authored
Jul 12, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add profile settings
parent
c3d58864
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
5 deletions
+113
-5
__init__.py
src/data/keyboards/__init__.py
+2
-2
profile.py
src/data/keyboards/profile.py
+23
-0
func.py
src/database/func.py
+18
-0
profile.py
src/handlers/profile.py
+70
-3
No files found.
src/data/keyboards/__init__.py
View file @
0f074af2
from
.
import
start
as
start_keyboards
from
.
import
menu
as
menu_keyboards
\ No newline at end of file
from
.
import
menu
as
menu_keyboards
from
.
import
profile
as
profile_keyboards
src/data/keyboards/profile.py
0 → 100644
View file @
0f074af2
from
telegrinder
import
InlineKeyboard
,
InlineButton
from
config
import
DEFAUIL_BRANCHES
profile_kb
=
(
InlineKeyboard
()
.
add
(
InlineButton
(
"Настройки"
,
callback_data
=
"profile/settings"
))
)
.
get_markup
()
profile_settings_kb
=
(
InlineKeyboard
()
.
add
(
InlineButton
(
"Сменить сопровождающего"
,
callback_data
=
"profile/settings/maintainer"
))
.
row
()
.
add
(
InlineButton
(
"Сменить репозиторий"
,
callback_data
=
"profile/settings/branch"
))
)
.
get_markup
()
def
profile_settings_branch_kb
():
kb
=
InlineKeyboard
()
for
branch
in
DEFAUIL_BRANCHES
:
kb
.
add
(
InlineButton
(
f
"{branch}"
,
callback_data
=
f
"profile/settings/branch/{branch}"
))
return
kb
.
get_markup
()
\ No newline at end of file
src/database/func.py
View file @
0f074af2
...
...
@@ -33,6 +33,24 @@ class UserMethod:
user
.
delete_instance
()
return
True
@classmethod
def
change_maintainer
(
cls
,
user_id
:
int
,
maintainer
:
str
):
user
=
cls
.
get
(
user_id
)
if
user
is
None
:
return
False
user
.
maintainer
=
maintainer
user
.
save
()
return
True
@classmethod
def
change_default_branch
(
cls
,
user_id
:
int
,
default_branch
:
str
):
user
=
cls
.
get
(
user_id
)
if
user
is
None
:
return
False
user
.
default_branch
=
default_branch
user
.
save
()
return
True
class
DB
:
user
=
UserMethod
src/handlers/profile.py
View file @
0f074af2
from
telegrinder
import
Dispatch
,
Message
,
CallbackQuery
from
telegrinder.rules
import
Command
,
PayloadEqRule
,
Text
,
IsUser
from
telegrinder
import
Dispatch
,
Message
,
CallbackQuery
,
MESSAGE_FROM_USER
,
WaiterMachine
from
telegrinder.rules
import
Command
,
PayloadEqRule
,
PayloadMarkupRule
,
Text
,
IsUser
,
HasText
from
database.func
import
DB
from
data.keyboards
import
profile_keyboards
from
api
import
api
from
api.models
import
BugzillaInfoModel
...
...
@@ -9,6 +12,7 @@ from services.menu import send_menu
from
database.models
import
User
dp
=
Dispatch
()
wm
=
WaiterMachine
(
dp
)
dp
.
message
.
auto_rules
=
IsUser
()
...
...
@@ -29,9 +33,72 @@ async def profile_handler(m: Message, user: User | None) -> None:
f
"Исходные пакеты: {maintainer.count_source_pkg}
\n
"
"
\n
"
f
"Всего багов: {bugs_data.length}
\n
"
f
"Открытых багов: {len(unresolved_bugs)}
\n
"
f
"Открытых багов: {len(unresolved_bugs)}
\n
"
,
reply_markup
=
profile_keyboards
.
profile_kb
)
@dp.callback_query
(
PayloadEqRule
(
"profile/settings"
))
async
def
callback_confirm_handler
(
cb
:
CallbackQuery
)
->
None
:
await
cb
.
ctx_api
.
send_message
(
chat_id
=
cb
.
from_user
.
id
,
text
=
"Настройки"
,
reply_markup
=
profile_keyboards
.
profile_settings_kb
)
@dp.callback_query
(
PayloadEqRule
(
"profile/settings/maintainer"
))
async
def
callback_confirm_handler
(
cb
:
CallbackQuery
)
->
None
:
await
cb
.
ctx_api
.
send_message
(
chat_id
=
cb
.
from_user
.
id
,
text
=
"Введите никнейм сопровождающего:"
,
)
api_data
=
await
api
.
site
.
all_maintainers
(
"sisyphus"
)
while
True
:
msg
,
_
=
await
wm
.
wait
(
MESSAGE_FROM_USER
,
cb
.
from_user
.
id
,
release
=
HasText
())
maintainer
=
msg
.
text
.
unwrap
()
.
lower
()
if
any
(
_m
.
packager_nickname
==
maintainer
for
_m
in
api_data
.
maintainers
):
await
msg
.
answer
(
f
"Вы выбрали {maintainer}"
)
DB
.
user
.
change_maintainer
(
cb
.
from_user
.
id
,
maintainer
)
break
else
:
await
msg
.
answer
(
f
"Сопровождающий {maintainer} не найден.
\n
"
"Введите никнейм сопровождающего:"
)
@dp.callback_query
(
PayloadEqRule
(
"profile/settings/branch"
))
async
def
callback_confirm_handler
(
cb
:
CallbackQuery
)
->
None
:
await
cb
.
ctx_api
.
edit_message_text
(
chat_id
=
cb
.
from_user
.
id
,
text
=
"Выберите репозиторий"
,
message_id
=
cb
.
message_id
.
unwrap
()
)
await
cb
.
ctx_api
.
edit_message_reply_markup
(
chat_id
=
cb
.
from_user
.
id
,
reply_markup
=
profile_keyboards
.
profile_settings_branch_kb
(),
message_id
=
cb
.
message_id
.
unwrap
()
)
@dp.callback_query
(
PayloadMarkupRule
(
"profile/settings/branch/<branch>"
))
async
def
callback_confirm_handler
(
cb
:
CallbackQuery
,
branch
:
str
)
->
None
:
await
cb
.
ctx_api
.
edit_message_text
(
chat_id
=
cb
.
from_user
.
id
,
text
=
f
"Вы выбрали {branch}"
,
message_id
=
cb
.
message_id
.
unwrap
()
)
DB
.
user
.
change_default_branch
(
cb
.
from_user
.
id
,
branch
)
@dp.callback_query
(
PayloadEqRule
(
"command/menu"
))
async
def
menu_handler
(
cb
:
CallbackQuery
,
user
:
User
|
None
):
send_menu
(
cb
,
user
)
...
...
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