hotpocket/services/packages/soa/hotpocket_soa/services/bot.py
Tomek Wójcik d909391ee6
Some checks failed
CI / Checks (push) Has been cancelled
Release v1.0.0rc1
2025-08-18 07:09:27 +02:00

41 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
from hotpocket_backend.apps.bot.services import BotService as BackendBotService
from hotpocket_soa.dto import BotResultOut
from .base import ProxyService, SOAError
class BotService(ProxyService):
class BotServiceError(SOAError):
pass
def __init__(self):
super().__init__()
self.backend_associations_service = BackendBotService()
def wrap_exception(self, exception: Exception) -> Exception:
new_exception_args = []
if len(exception.args) > 0:
new_exception_args = [exception.args[0]]
return self.BotServiceError(*new_exception_args)
def is_netloc_banned(self, *, url: str) -> bool:
return self.call(
self.backend_associations_service,
'is_netloc_banned',
url=url,
)
def handle(self, *, url: str) -> BotResultOut:
return BotResultOut.model_validate(
self.call(
self.backend_associations_service,
'handle',
url=url,
),
from_attributes=True,
)