Fixed reply waiting
This commit is contained in:
parent
cccf134a58
commit
8d5554855f
8
hooks.py
8
hooks.py
|
|
@ -71,7 +71,7 @@ class ChannelHook(AbsHook):
|
|||
Returns whether a message should be handled by this dict, returning a Match if so, or None
|
||||
"""
|
||||
# Ensure that this is an event in a specific channel, with a text component
|
||||
if not (event.conversation and event.post and event.message and event.user):
|
||||
if not (event.conversation and event.was_post and event.message and event.user):
|
||||
return None
|
||||
|
||||
# Fail if pattern invalid
|
||||
|
|
@ -129,7 +129,7 @@ class ReplyWaiter(AbsHook):
|
|||
raise HookDeath()
|
||||
|
||||
# Next make sure we're actually a message
|
||||
if not (event.post and event.post and event.thread and event.conversation and event.user):
|
||||
if not (event.was_post and event.was_post and event.thread and event.conversation and event.user):
|
||||
return None
|
||||
|
||||
# Otherwise proceed normally
|
||||
|
|
@ -138,7 +138,7 @@ class ReplyWaiter(AbsHook):
|
|||
return None
|
||||
|
||||
# Does it match the regex? if not, ignore
|
||||
match = re.match(self.pattern, event.post.text.strip(), flags=re.IGNORECASE)
|
||||
match = re.match(self.pattern, event.message.text.strip(), flags=re.IGNORECASE)
|
||||
if match:
|
||||
self.dead = True
|
||||
return self.callback(event, match)
|
||||
|
|
@ -147,7 +147,7 @@ class ReplyWaiter(AbsHook):
|
|||
|
||||
|
||||
# The associated generic type of a button - value mapping
|
||||
ActionVal = TypeVar("T")
|
||||
ActionVal = TypeVar("ActionVal")
|
||||
|
||||
|
||||
class InteractionListener(AbsHook):
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class Event:
|
|||
# Info on if a particular user caused this event, and if so which one
|
||||
user: Optional[UserContext] = None
|
||||
# Info on if this event was a someone posting a message. For contents see related
|
||||
post: Optional[PostMessageContext] = None
|
||||
was_post: Optional[PostMessageContext] = None
|
||||
# The content of the most relevant message to this event
|
||||
message: Optional[RelatedMessageContext] = None
|
||||
# Info if this event was threaded on a parent message, and if so what that message was
|
||||
|
|
@ -182,7 +182,7 @@ def message_dict_to_event(update: dict) -> Event:
|
|||
# TODO: Handle "unwrappeable" messages
|
||||
if "text" in update and "ts" in update:
|
||||
event.message = RelatedMessageContext(update["ts"], update["text"])
|
||||
event.post = PostMessageContext()
|
||||
event.was_post = PostMessageContext()
|
||||
if "channel" in update:
|
||||
event.conversation = ConversationContext(update["channel"])
|
||||
if "user" in update:
|
||||
|
|
|
|||
Loading…
Reference in New Issue