Skip to content

Commit

Permalink
test15
Browse files Browse the repository at this point in the history
  • Loading branch information
akiioto committed Oct 16, 2024
1 parent cb3c6a5 commit eba03ee
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions cmd/cloud-run/slack-message-sender/slack-message-sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def get_user_id_by_username(username: str) -> Optional[str]:

while True:
try:
response = slack_app.client.users_list(limit=200, cursor=next_cursor)
response = slack_app.client.users_list(limit=20, cursor=next_cursor)
except SlackApiError as e:
print(f"Slack API error: {e.response['error']}")
return None
Expand Down Expand Up @@ -237,7 +237,7 @@ def issue_labeled() -> Response:
if sender_slack_id:
sender_mention = f"<@{sender_slack_id}>"
else:
sender_mention = sender_login # Use GitHub login without mention
sender_mention = None

# Prepare assignee information
assignee_info = f"Issue #{number} in repository {org}/{repo} is assigned to {assignee_mention}"
Expand All @@ -248,55 +248,55 @@ def issue_labeled() -> Response:
message=f"Sending notification to {slack_team_channel_id}.",
**log_fields,
))

result = slack_app.client.chat_postMessage(
if not sender_mention:
result = slack_app.client.chat_postMessage(
channel=slack_team_channel_id,
text=f"Issue {title} #{number} labeled as {label} in {repo}",
username="GithubBot",
unfurl_links=True,
unfurl_media=True,
link_names=True,
blocks=[
{
"type": "context",
"elements": [
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://mpng.subpng.com/20180802/bfy/kisspng-portable-network-graphics-computer-icons-clip-art-caribbean-blue-tag-icon-free-caribbean-blue-pric-5b63afe8224040.3966331515332597521403.jpg",
"alt_text": "label"
},
{
"type": "mrkdwn",
"text": "SAP GitHub issue labeled"
}
]
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": f"SAP GitHub {label}"
}
"type": "image",
"image_url": "https://mpng.subpng.com/20180802/bfy/kisspng-portable-network-graphics-computer-icons-clip-art-caribbean-blue-tag-icon-free-caribbean-blue-pric-5b63afe8224040.3966331515332597521403.jpg",
"alt_text": "label"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": (
f"{sender_mention} labeled issue `{title}` as `{label}`.\n"
f"{assignee_info} <{issue_url}|See the issue here.>"
)
}
},
"type": "mrkdwn",
"text": "SAP GitHub issue labeled"
}
]
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": f"SAP GitHub {label}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": (
f"{sender_mention} labeled issue `{title}` as `{label}`.\n"
f"{assignee_info} <{issue_url}|See the issue here.>"
)
}
},
],
)
print(LogEntry(
severity="INFO",
message=f"Slack message sent, message id: {result['ts']}",
**log_fields,
))

return prepare_success_response()
)
print(LogEntry(
severity="INFO",
message=f"Slack message sent, message id: {result['ts']}",
**log_fields,
))

return prepare_success_response()

return prepare_error_response("Cannot parse pubsub data", log_fields)
except Exception as err:
Expand Down

0 comments on commit eba03ee

Please sign in to comment.