Fixed reply waiting

This commit is contained in:
Jacob Henry 2019-03-26 16:06:36 -04:00
parent cccf134a58
commit 8d5554855f
2 changed files with 6 additions and 6 deletions

View File

@ -71,7 +71,7 @@ class ChannelHook(AbsHook):
Returns whether a message should be handled by this dict, returning a Match if so, or None 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 # 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 return None
# Fail if pattern invalid # Fail if pattern invalid
@ -129,7 +129,7 @@ class ReplyWaiter(AbsHook):
raise HookDeath() raise HookDeath()
# Next make sure we're actually a message # 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 return None
# Otherwise proceed normally # Otherwise proceed normally
@ -138,7 +138,7 @@ class ReplyWaiter(AbsHook):
return None return None
# Does it match the regex? if not, ignore # 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: if match:
self.dead = True self.dead = True
return self.callback(event, match) return self.callback(event, match)
@ -147,7 +147,7 @@ class ReplyWaiter(AbsHook):
# The associated generic type of a button - value mapping # The associated generic type of a button - value mapping
ActionVal = TypeVar("T") ActionVal = TypeVar("ActionVal")
class InteractionListener(AbsHook): class InteractionListener(AbsHook):

View File

@ -65,7 +65,7 @@ class Event:
# Info on if a particular user caused this event, and if so which one # Info on if a particular user caused this event, and if so which one
user: Optional[UserContext] = None user: Optional[UserContext] = None
# Info on if this event was a someone posting a message. For contents see related # 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 # The content of the most relevant message to this event
message: Optional[RelatedMessageContext] = None message: Optional[RelatedMessageContext] = None
# Info if this event was threaded on a parent message, and if so what that message was # 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 # TODO: Handle "unwrappeable" messages
if "text" in update and "ts" in update: if "text" in update and "ts" in update:
event.message = RelatedMessageContext(update["ts"], update["text"]) event.message = RelatedMessageContext(update["ts"], update["text"])
event.post = PostMessageContext() event.was_post = PostMessageContext()
if "channel" in update: if "channel" in update:
event.conversation = ConversationContext(update["channel"]) event.conversation = ConversationContext(update["channel"])
if "user" in update: if "user" in update: