Opsdroid-RasaSR/__init__.py

18 lines
797 B
Python
Raw Normal View History

2021-11-03 11:57:55 +00:00
from opsdroid.skill import Skill
from opsdroid.matchers import match_rasanlu, match_parse
import random
class Respond(Skill):
def __init__(self, opsdroid, config):
super().__init__(opsdroid, config)
self.intent = self.config.get("intent")
self.respond = match_rasanlu(self.intent)(self.respond)
# This line is to add properties to respond on declaration
# as doing this in __init__ would cause an exception to be
# raised. If you don't believe me, remove it!
@match_parse("hgftgyhjknbvhgftyuihjkvhgftyuijkbjhgtyyuijhkjghfdtrytyihujkbvncgfxdtrytuyiuhkbjvbhcfdytryuhjkbvhcfdyrtuyiuhkbhj")
async def respond(self, message):
response_options = self.config.get("response_options")
await message.respond(random.choice(response_options))