Skip to content

Commit 2601278

Browse files
committed
Fix annotations
1 parent 3aeb43c commit 2601278

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/redis_release/slack_bot.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import logging
55
import os
66
import re
7-
from typing import Optional
7+
from typing import Any, Dict, Optional
88

99
from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler
1010
from slack_bolt.async_app import AsyncApp
11+
from slack_bolt.context.say.async_say import AsyncSay
1112

1213
from redis_release.config import Config, load_config
1314
from redis_release.models import ReleaseArgs
@@ -71,7 +72,9 @@ def _register_handlers(self) -> None:
7172
"""Register Slack event handlers."""
7273

7374
@self.app.event("app_mention")
74-
async def handle_app_mention(event, say, logger) -> None:
75+
async def handle_app_mention( # pyright: ignore[reportUnusedFunction]
76+
event: Dict[str, Any], say: AsyncSay, logger: logging.Logger
77+
) -> None:
7578
"""Handle app mentions and check for status requests."""
7679
try:
7780
text = event.get("text", "").lower()
@@ -82,6 +85,13 @@ async def handle_app_mention(event, say, logger) -> None:
8285
"thread_ts", ts
8386
) # Use thread_ts if in thread, else use message ts
8487

88+
# Validate required fields
89+
if not channel or not user or not thread_ts:
90+
logger.error(
91+
f"Missing required fields in event: channel={channel}, user={user}, thread_ts={thread_ts}"
92+
)
93+
return
94+
8595
logger.info(
8696
f"Received mention from user {user} in channel {channel}: {text}"
8797
)
@@ -118,10 +128,11 @@ async def handle_app_mention(event, say, logger) -> None:
118128
except Exception as e:
119129
logger.error(f"Error handling app mention: {e}", exc_info=True)
120130
# Reply in thread if configured
121-
if self.reply_in_thread:
131+
channel = event.get("channel")
132+
if self.reply_in_thread and channel:
122133
await self.app.client.chat_postMessage(
123-
channel=event.get("channel"),
124-
thread_ts=event.get("thread_ts", event.get("ts")),
134+
channel=channel,
135+
thread_ts=event.get("thread_ts", event.get("ts", "")),
125136
text=f"Sorry, I encountered an error: {str(e)}",
126137
)
127138
else:

0 commit comments

Comments
 (0)