Skip to content

Commit

Permalink
fixed webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
ychebyshev committed Feb 4, 2024
1 parent 6f49070 commit e04e662
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion config_dist/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bot:
botapi-file-url: "http://nginx:80"
webhook:
web-url: https://example.org/context/path
local-url: 127.0.0.1:8080/
path: /bot
secret: my-$ecr3t
db:
Expand Down
10 changes: 4 additions & 6 deletions shvatka/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@ def main() -> FastAPI:
secret_token=webhook_config.secret,
)
webhook_handler.register(app, webhook_config.path)
logger.info(webhook_config.web_url)
logger.info(webhook_config.path)

setup = partial(on_startup, builder, webhook_config)
app.router.add_event_handler("startup", setup)
logger.info("app prepared")

root_app = FastAPI()
root_app.mount(api_config.context_path, app)
setup = partial(on_startup, builder, webhook_config)
root_app.router.add_event_handler("startup", setup)
logger.info("app prepared")
return root_app


async def on_startup(dp_builder: DpBuilder, webhook_config: WebhookConfig):
await dp_builder.start()
logger.info(webhook_config.web_url + webhook_config.path)
await dp_builder.bot.set_webhook(
url=webhook_config.web_url + webhook_config.path,
secret_token=webhook_config.secret,
Expand Down
1 change: 0 additions & 1 deletion shvatka/tgbot/config/models/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ class BotApiType(Enum):
@dataclass
class WebhookConfig:
web_url: str
local_url: str
path: str
secret: str
1 change: 0 additions & 1 deletion tests/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bot:
type: official
webhook:
web-url: https://example.org/context/path
local-url: 127.0.0.1:8080/
path: secret/path
secret: my-$ecr3t
redis:
Expand Down

0 comments on commit e04e662

Please sign in to comment.