utils.github_webhook: fix _get_event_title() and _format_ping() for organizations

This commit is contained in:
Dash Eclipse
2021-04-22 14:28:19 +00:00
parent 329c1b947e
commit 62afb6828b
2 changed files with 7 additions and 12 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ You need a Telegram bot token, create a Telegram bot with
URL", "Content Type" (must be `application/json`) and "Secret". You can also
do this after start running the project.
2. Copy `config_sample.json` to `config.json` to configure it. `chat_id` can be
user/group/channel id (integer) or username (string), make sure the bot is
`/start`ed or member of the chat with permission to send messages
user id or group/channel id/username, make sure the bot is `/start`ed or
member of the chat with permission to send messages
3. Configure reverse proxy for this app, corresponding configuration for Nginx
looks like this
```
+5 -10
View File
@@ -130,12 +130,8 @@ async def _format_issues(payload: dict) -> str:
)
async def _format_ping(payload: dict) -> str:
repository = payload['repository']
return "\u2192 <a href=\"{url}\">{name}</a>".format(
url=repository['html_url'],
name=repository['full_name']
)
async def _format_ping(_: dict) -> None:
return None
async def _format_public(payload: dict) -> str:
@@ -181,15 +177,14 @@ async def _format_star(payload: dict) -> str:
async def _get_event_title(event: str, payload: dict) -> str:
name = (payload.get('repository', {}).get('full_name')
or payload.get('organization', {}).get('login'))
summary = [payload['sender']['login']]
# if action := payload.get('action'): summary.append(action)
action = payload.get('action')
summary.append(action) if action else []
summary.append(event)
return "<b>{name}</b> | <i>{summary}</i>".format(
name=payload['repository']['full_name'],
summary=" ".join(summary)
)
return f"<b>{name}</b> | <i>{' '.join(summary)}</i>"
async def _get_repo_star_and_fork(repo: dict) -> str: