Open Resisty opened 6 years ago
There are the following ways to receive multiline messages.
@listen_to('XXXX')
def hoge(message):
text = message.body['text']
# text is multiline messages
I have the bot up and running ... so 1st off thank you
but I am not able to get the bot to listen and respond with multiline messages...I presume I'm missing a simple detail.
For Ex. anytime the bot name is mentioned...I want to the bot to look at the message and if any of my keywords are within the message then proceed to do something
@listen_to("my bot name") ---> here is where I presume I'm going wrong. I need the bot to look at the message and then see if any keywords ??? def listening(message): msg = message.body['text'] if key_word list in msg: do stuff
Appreciate the help
This worked for me.
def main():
bot = Bot()
# make @respond_to receive multi-line messages
bot._dispatcher.AT_MESSAGE_MATCHER = re.compile(
bot._dispatcher.AT_MESSAGE_MATCHER.pattern, re.S | re.M
)
bot.run()
It looks like this should work out of the box (judging by https://github.com/Rycieos/slack-compilebot) but I can't get my bot to respond to multiline messages, like:
I've tried creating handlers like:
and various other patterns like
r'([\s\S\n]*)'
,r'(.*)', re.I|re.S
but I can't figure out how get the bot to respond to multiline messages. Any advice or tips would be much appreciated!