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
d663ab0b
Verified
Commit
d663ab0b
authored
Jul 20, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base: add api version test
parent
86fd4380
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
methods.py
src/altrepo/api/methods.py
+1
-0
help.py
src/handlers/help.py
+6
-1
main.py
src/main.py
+7
-0
test_api_version.py
src/services/test_api_version.py
+17
-0
No files found.
src/altrepo/api/methods.py
View file @
d663ab0b
...
...
@@ -150,6 +150,7 @@ class SiteInfo:
class
ALTRepoAPI
:
def
__init__
(
self
,
session
:
aiohttp
.
ClientSession
):
self
.
BASE_API_VERSION
=
"1.19.31"
self
.
_client
=
BaseAPI
(
session
)
self
.
api
=
APIInfo
(
self
.
_client
)
self
.
package
=
PackageInfo
(
self
.
_client
)
...
...
src/handlers/help.py
View file @
d663ab0b
...
...
@@ -8,7 +8,12 @@ dp = Dispatch()
@dp.message
(
Command
(
"altrepo_info"
))
async
def
info_handler
(
m
:
Message
)
->
None
:
api_data
=
await
altrepo
.
api
.
version
()
warn
=
(
f
"Бот разработан под версию API {altrepo.api.BASE_API_VERSION} и может работать нестабильно.
\n
"
"Разработчик уже уведомлён."
)
await
m
.
answer
(
"Telegram бот для портала packages.altlinux.org
\n
"
f
"Версия API: {api_data.version}"
f
"Версия API: {api_data.version}
\n\n
"
f
"{warn if api_data.version != altrepo.api.BASE_API_VERSION else ""}"
)
src/main.py
View file @
d663ab0b
...
...
@@ -9,6 +9,8 @@ from altrepo.api.errors import TooManyRequests
from
database.models
import
db
,
User
from
middlewares
import
UserMiddleware
from
services.test_api_version
import
test_api_version
bot
=
Telegrinder
(
tg_api
)
bot
.
dispatch
.
load_from_dir
(
"src/handlers"
)
...
...
@@ -19,6 +21,7 @@ async def startup():
db
.
create_tables
([
User
])
logger
.
info
(
"initializing ALTRepo"
)
await
altrepo
.
init
()
await
test_api_version
()
await
bot
.
api
.
set_my_commands
(
commands
=
[
BotCommand
(
"watch"
,
"Отслеживание по пакетам"
),
BotCommand
(
"bugs"
,
"Отслеживание по ошибкам"
)
...
...
@@ -29,6 +32,10 @@ async def shutdown():
logger
.
info
(
"stopping ALTRepo"
)
await
altrepo
.
close
()
@bot.loop_wrapper.interval
(
days
=
1
)
async
def
api_test
():
await
test_api_version
()
@bot.on.error
()
async
def
error_handler
(
err
:
Error
[
TooManyRequests
],
m
:
Message
):
await
m
.
answer
(
f
"Слишком много запросов!"
)
...
...
src/services/test_api_version.py
0 → 100644
View file @
d663ab0b
from
telegrinder.modules
import
logger
from
config
import
config
,
tg_api
from
altrepo
import
altrepo
async
def
test_api_version
():
api_data
=
await
altrepo
.
api
.
version
()
if
api_data
.
version
!=
altrepo
.
api
.
BASE_API_VERSION
:
logger
.
error
(
f
"The API version is outdated: {altrepo.api.BASE_API_VERSION} -> {api_data.version}"
)
for
adm_id
in
config
.
admins
:
await
tg_api
.
send_message
(
chat_id
=
adm_id
,
text
=
f
"[ERROR] Версия API устарела: {altrepo.api.BASE_API_VERSION} -> {api_data.version}"
)
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