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
8f31b07f
Verified
Commit
8f31b07f
authored
Aug 12, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
package module: add install button
parent
73d33c09
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
6 deletions
+43
-6
methods.py
src/altrepo/appstream/methods.py
+2
-4
config.py
src/config.py
+1
-1
__init__.py
src/data/keyboards/__init__.py
+1
-0
package.py
src/data/keyboards/package.py
+15
-0
package.py
src/handlers/package.py
+24
-1
No files found.
src/altrepo/appstream/methods.py
View file @
8f31b07f
...
...
@@ -76,12 +76,10 @@ class PackageInfo:
context
=
etree
.
iterparse
(
path
,
events
=
(
"end"
,),
recover
=
True
)
for
_
,
elem
in
context
:
if
elem
.
tag
==
"component"
:
if
elem
.
tag
==
"component"
and
elem
.
get
(
"type"
)
!=
"addon"
:
if
elem
.
findtext
(
"pkgname"
)
==
pkgname
:
return
elem
.
findtext
(
"id"
)
elem
.
clear
()
while
elem
.
getprevious
()
is
not
None
:
del
elem
.
getparent
()[
0
]
elem
.
clear
()
return
None
...
...
src/config.py
View file @
8f31b07f
...
...
@@ -30,7 +30,7 @@ DEFAUIL_BRANCHES = [
BUGS_URL
=
"https://bugzilla.altlinux.org/"
PACKAGES_URL
=
"https://packages.altlinux.org/ru/{repo}/"
CYBERTALK_URL
=
"https://lists.altlinux.org/pipermail/sisyphus-cybertalk/{}/"
INSTALL_APP_URL
=
"https://appstream.k8s.eterfund.ru/app/{app_id}/"
# ====== BOT
...
...
src/data/keyboards/__init__.py
View file @
8f31b07f
...
...
@@ -2,6 +2,7 @@ from . import admin as admin_keyboards
from
.
import
start
as
start_keyboards
from
.
import
menu
as
menu_keyboards
from
.
import
news
as
news_keyboards
from
.
import
package
as
package_keyboards
from
.
import
profile
as
profile_keyboards
from
.
import
watch
as
watch_keyboards
from
.
import
bugs
as
bugs_keyboards
src/data/keyboards/package.py
0 → 100644
View file @
8f31b07f
from
typing
import
List
from
telegrinder
import
InlineKeyboard
,
InlineButton
from
config
import
INSTALL_APP_URL
def
appstream_install_app_kb
(
ids
:
List
[
str
],
names
:
List
[
str
]):
kb
=
InlineKeyboard
()
for
app_id
,
name
in
zip
(
ids
,
names
):
kb
.
add
(
InlineButton
(
text
=
f
"Установить {name}"
,
url
=
INSTALL_APP_URL
.
format
(
app_id
=
app_id
)
))
kb
.
row
()
return
kb
.
get_markup
()
src/handlers/package.py
View file @
8f31b07f
...
...
@@ -6,6 +6,7 @@ from datetime import datetime
from
altrepo
import
altrepo
from
altrepo.api.errors
import
DataNotFoundError
,
RequestValidationError
from
data.keyboards
import
package_keyboards
from
database.models
import
User
from
database.func
import
DB
from
services.utils
import
_bold
...
...
@@ -59,6 +60,14 @@ async def package_info_handler(
if
arch
:
source_package
=
package
.
package_archs
[
0
]
.
name
appstream_id
=
altrepo
.
appstream
.
package
.
id_by_pkgname
(
package
.
name
,
branch
)
if
appstream_id
:
appstream_ids
=
[
appstream_id
]
else
:
appstream_ids
=
[]
appstream_names
=
[
package
.
name
]
new_version
=
None
if
not
arch
:
...
...
@@ -70,6 +79,8 @@ async def package_info_handler(
f
" Новая версия: {new_version[0].version}-{new_version[0].release}"
)
appstream_ids
=
[]
appstream_names
=
[]
binary_packages_message
=
_bold
(
"
\n\n
Бинарные пакеты:
\n
"
)
for
i
,
binary_package
in
enumerate
(
package
.
package_archs
):
if
i
==
15
:
...
...
@@ -77,6 +88,13 @@ async def package_info_handler(
break
binary_packages_message
+=
f
" {binary_package.name}"
binary_packages_message
+=
f
" ({"
,
".join(binary_package.archs)})
\n
"
app_id
=
altrepo
.
appstream
.
package
.
id_by_pkgname
(
binary_package
.
name
,
branch
)
if
app_id
:
appstream_ids
.
append
(
app_id
)
appstream_names
.
append
(
binary_package
.
name
)
_package
=
DB
.
package
.
get
(
package
.
name
)
summary
=
(
...
...
@@ -99,4 +117,9 @@ async def package_info_handler(
f
"{f"
{
binary_packages_message
}
" if not arch else ""}"
)
await
m
.
answer
(
message
)
await
m
.
answer
(
message
,
reply_markup
=
package_keyboards
.
appstream_install_app_kb
(
appstream_ids
,
appstream_names
)
if
appstream_ids
else
None
)
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