utils.github_webhook: fix _get_event_title() and _format_ping() for organizations
This commit is contained in:
@@ -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
|
URL", "Content Type" (must be `application/json`) and "Secret". You can also
|
||||||
do this after start running the project.
|
do this after start running the project.
|
||||||
2. Copy `config_sample.json` to `config.json` to configure it. `chat_id` can be
|
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
|
user id or group/channel id/username, make sure the bot is `/start`ed or
|
||||||
`/start`ed or member of the chat with permission to send messages
|
member of the chat with permission to send messages
|
||||||
3. Configure reverse proxy for this app, corresponding configuration for Nginx
|
3. Configure reverse proxy for this app, corresponding configuration for Nginx
|
||||||
looks like this
|
looks like this
|
||||||
```
|
```
|
||||||
|
|||||||
+5
-10
@@ -130,12 +130,8 @@ async def _format_issues(payload: dict) -> str:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def _format_ping(payload: dict) -> str:
|
async def _format_ping(_: dict) -> None:
|
||||||
repository = payload['repository']
|
return None
|
||||||
return "\u2192 <a href=\"{url}\">{name}</a>".format(
|
|
||||||
url=repository['html_url'],
|
|
||||||
name=repository['full_name']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def _format_public(payload: dict) -> str:
|
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:
|
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']]
|
summary = [payload['sender']['login']]
|
||||||
# if action := payload.get('action'): summary.append(action)
|
# if action := payload.get('action'): summary.append(action)
|
||||||
action = payload.get('action')
|
action = payload.get('action')
|
||||||
summary.append(action) if action else []
|
summary.append(action) if action else []
|
||||||
summary.append(event)
|
summary.append(event)
|
||||||
return "<b>{name}</b> | <i>{summary}</i>".format(
|
return f"<b>{name}</b> | <i>{' '.join(summary)}</i>"
|
||||||
name=payload['repository']['full_name'],
|
|
||||||
summary=" ".join(summary)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def _get_repo_star_and_fork(repo: dict) -> str:
|
async def _get_repo_star_and_fork(repo: dict) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user