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
e0ed0a49
Verified
Commit
e0ed0a49
authored
Jul 12, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add watch
parent
e0b551e3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
1 deletion
+64
-1
methods.py
src/api/methods.py
+7
-0
models.py
src/api/models.py
+15
-0
menu.py
src/data/keyboards/menu.py
+3
-0
watch.py
src/handlers/watch.py
+34
-0
main.py
src/main.py
+5
-1
No files found.
src/api/methods.py
View file @
e0ed0a49
...
@@ -83,6 +83,13 @@ class SiteInfo:
...
@@ -83,6 +83,13 @@ class SiteInfo:
)
)
return
models
.
MaintainerInfoModel
(
**
data
)
return
models
.
MaintainerInfoModel
(
**
data
)
async
def
watch_by_maintainer
(
self
,
maintainer_nickname
:
str
)
->
models
.
SiteWatchByMaintainerModel
:
data
=
await
self
.
client
.
get
(
"/site/watch_by_maintainer"
,
{
"maintainer_nickname"
:
maintainer_nickname
}
)
return
models
.
SiteWatchByMaintainerModel
(
**
data
)
class
PackagesAPI
:
class
PackagesAPI
:
def
__init__
(
self
):
def
__init__
(
self
):
...
...
src/api/models.py
View file @
e0ed0a49
...
@@ -45,6 +45,21 @@ class AllMaintainersModel(BaseModel):
...
@@ -45,6 +45,21 @@ class AllMaintainersModel(BaseModel):
maintainers
:
List
[
AllMaintainersElementModel
]
maintainers
:
List
[
AllMaintainersElementModel
]
class
SiteWatchByMaintainerElementModel
(
BaseModel
):
pkg_name
:
str
old_version
:
str
new_version
:
str
repology_name
:
str
url
:
str
date_update
:
str
class
SiteWatchByMaintainerModel
(
BaseModel
):
request_args
:
Dict
[
str
,
Any
]
length
:
int
packages
:
List
[
SiteWatchByMaintainerElementModel
]
class
BugzillaInfoElementModel
(
BaseModel
):
class
BugzillaInfoElementModel
(
BaseModel
):
id
:
str
id
:
str
status
:
str
status
:
str
...
...
src/data/keyboards/menu.py
View file @
e0ed0a49
...
@@ -4,5 +4,7 @@ menu_kb = (
...
@@ -4,5 +4,7 @@ menu_kb = (
Keyboard
()
Keyboard
()
.
add
(
Button
(
"Профиль"
))
.
add
(
Button
(
"Профиль"
))
.
row
()
.
row
()
.
add
(
Button
(
"Отслеживание"
))
.
row
()
.
add
(
Button
(
"Статистика"
))
.
add
(
Button
(
"Статистика"
))
)
.
get_markup
()
)
.
get_markup
()
\ No newline at end of file
src/handlers/watch.py
0 → 100644
View file @
e0ed0a49
from
telegrinder
import
Dispatch
,
Message
from
telegrinder.rules
import
Command
,
Text
,
IsUser
from
telegrinder.tools.formatting
import
HTMLFormatter
from
telegrinder.types
import
LinkPreviewOptions
from
api
import
api
from
api.models
import
BugzillaInfoModel
from
services.menu
import
send_menu
from
database.models
import
User
dp
=
Dispatch
()
dp
.
message
.
auto_rules
=
IsUser
()
@dp.message
(
Command
(
"watch"
)
|
Text
([
"watch"
,
"отслеживание"
],
ignore_case
=
True
))
async
def
watch_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
if
user
is
None
:
return
watch_data
=
await
api
.
site
.
watch_by_maintainer
(
user
.
maintainer
)
watch_message
=
"Отслеживание:
\n\n
"
for
i
,
package
in
enumerate
(
watch_data
.
packages
):
watch_message
+=
f
"{package.pkg_name}: {package.old_version} -> "
+
\
HTMLFormatter
(
f
"<a href='{package.url}'>{package.new_version}</a>"
)
+
"
\n
"
if
i
==
35
:
break
await
m
.
answer
(
watch_message
)
src/main.py
View file @
e0ed0a49
from
telegrinder
import
API
,
Telegrinder
,
Token
from
telegrinder
import
API
,
Telegrinder
,
Token
from
telegrinder.modules
import
logger
from
telegrinder.modules
import
logger
from
telegrinder.tools.formatting
import
HTMLFormatter
from
config
import
config
from
config
import
config
from
api
import
api
from
api
import
api
...
@@ -8,7 +9,10 @@ from middlewares import UserMiddleware
...
@@ -8,7 +9,10 @@ from middlewares import UserMiddleware
logger
.
set_level
(
"INFO"
)
logger
.
set_level
(
"INFO"
)
bot
=
Telegrinder
(
API
(
token
=
Token
(
config
.
BOT_TOKEN
)))
tg_api
=
API
(
token
=
Token
(
config
.
BOT_TOKEN
))
tg_api
.
default_params
[
"parse_mode"
]
=
HTMLFormatter
.
PARSE_MODE
bot
=
Telegrinder
(
tg_api
)
bot
.
dispatch
.
load_from_dir
(
"src/handlers"
)
bot
.
dispatch
.
load_from_dir
(
"src/handlers"
)
bot
.
on
.
message
.
register_middleware
(
UserMiddleware
)
bot
.
on
.
message
.
register_middleware
(
UserMiddleware
)
...
...
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