Now detects bots
This commit is contained in:
parent
3c01e1782a
commit
d75d72b6d5
|
|
@ -69,6 +69,7 @@ class Event:
|
||||||
message: Optional[MessageContext] = None
|
message: Optional[MessageContext] = None
|
||||||
thread: Optional[ThreadContext] = None
|
thread: Optional[ThreadContext] = None
|
||||||
interaction: Optional[InteractiveContext] = None
|
interaction: Optional[InteractiveContext] = None
|
||||||
|
bot: Optional[BotContext] = None
|
||||||
|
|
||||||
|
|
||||||
# If this was posted in a specific channel or conversation
|
# If this was posted in a specific channel or conversation
|
||||||
|
|
@ -89,6 +90,12 @@ class UserContext:
|
||||||
return get_slack().get_user(self.user_id)
|
return get_slack().get_user(self.user_id)
|
||||||
|
|
||||||
|
|
||||||
|
# Same but for bots
|
||||||
|
@dataclass
|
||||||
|
class BotContext:
|
||||||
|
bot_id: str
|
||||||
|
|
||||||
|
|
||||||
# Whether or not this is a threadable text message
|
# Whether or not this is a threadable text message
|
||||||
@dataclass
|
@dataclass
|
||||||
class MessageContext:
|
class MessageContext:
|
||||||
|
|
@ -168,6 +175,8 @@ def message_dict_to_event(update: dict) -> Event:
|
||||||
event.conversation = ConversationContext(update["channel"])
|
event.conversation = ConversationContext(update["channel"])
|
||||||
if "user" in update:
|
if "user" in update:
|
||||||
event.user = UserContext(update["user"])
|
event.user = UserContext(update["user"])
|
||||||
|
if "bot_id" in update:
|
||||||
|
event.bot = BotContext(update["bot_id"])
|
||||||
if "thread_ts" in update:
|
if "thread_ts" in update:
|
||||||
event.thread = ThreadContext(update["thread_ts"])
|
event.thread = ThreadContext(update["thread_ts"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ def fmt_work_dict(work_dict: dict) -> str:
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
async def count_work_callback(event: slack_util.Event, match: Match) -> None:
|
async def count_work_callback(event: slack_util.Event, match: Match) -> None:
|
||||||
|
# If no user, continue
|
||||||
|
if event.user is None:
|
||||||
|
return
|
||||||
|
|
||||||
# Make an error wrapper
|
# Make an error wrapper
|
||||||
verb = slack_util.VerboseWrapper(event)
|
verb = slack_util.VerboseWrapper(event)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue