So in the GroupMe Bot I'm working on - I've gotten the bot to respond by passing messages with an if statement in the webhooks.
def webhook():
# 'message' is an object that represents a single GroupMe message.
message = request.get_json()
speaker = message['name']
# If hypefact! is spoken, return random fact
# This code replies once and then calls another function that replies again
if 'hypefact!' in message['text'].lower() and not sender_is_bot(message):
reply(speaker + ' - Here is your Hype Fact: ')
reply(fact_delivery())
Now below is the function for get_weather
def get_weather(city):
## Bunch of stuff happens
reply(weatherData['currently']['summary'] + ', ' + str(
weatherData['currently']['apparentTemperature']) + degree_sign + 'F. ' + weatherData['hourly'][
'summary'] + '\n\n' + weatherData['daily']['summary'])
If a phrase is "in message['text']" it will trigger an action because it is in the message.
What if I was trying to get it to parse this message.
"Whats the weather in Austin this weekend"
The key part of that phrase is "weather in Austin"
So I want to take the word after "in" and parse that to get_weather(city)
Expected workflow: person in chat says phrase with "weather in {CITY}" in the message bot triggers, filters city out of the string to call get_weather function