|
|
@ -62,23 +62,24 @@ class Callbacks(object): |
|
|
|
chat_message = self.bot.chat_history.room(room.room_id).add(event.event_id, event.server_timestamp, room.user_name(event.sender), event.sender == self.client.user, is_command, relates_to, event.body, language, english_original_message) |
|
|
|
|
|
|
|
# parse keywords |
|
|
|
self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []} |
|
|
|
for i, keyword in enumerate(self.bot.keywords): |
|
|
|
if re.search(keyword["regex"], event.body, flags=re.IGNORECASE): |
|
|
|
if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1: |
|
|
|
self.bot.chat_history.room(room.room_id).setFastForward(False) |
|
|
|
self.bot.keywords[i]['active'] = int(keyword["duration"]) |
|
|
|
logger.info(f"keyword \"{keyword['regex']}\" detected") |
|
|
|
if 'active' in self.bot.keywords[i]: |
|
|
|
if self.bot.keywords[i]['active'] > 0: |
|
|
|
logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})") |
|
|
|
if 'example_dialogue' in keyword: |
|
|
|
self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue']) |
|
|
|
if 'persona' in keyword: |
|
|
|
self.bot.extra_info['persona'].append(keyword['persona']) |
|
|
|
if 'scenario' in keyword: |
|
|
|
self.bot.extra_info['scenario'].append(keyword['scenario']) |
|
|
|
self.bot.keywords[i]["active"] -= 1 |
|
|
|
if not event.body.startswith('!') and not event.body.startswith('<ERROR>') |
|
|
|
self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []} |
|
|
|
for i, keyword in enumerate(self.bot.keywords): |
|
|
|
if re.search(keyword["regex"], event.body, flags=re.IGNORECASE): |
|
|
|
if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1: |
|
|
|
self.bot.chat_history.room(room.room_id).setFastForward(False) |
|
|
|
self.bot.keywords[i]['active'] = int(keyword["duration"]) |
|
|
|
logger.info(f"keyword \"{keyword['regex']}\" detected: \"{event.body}\"") |
|
|
|
if 'active' in self.bot.keywords[i]: |
|
|
|
if self.bot.keywords[i]['active'] > 0: |
|
|
|
logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})") |
|
|
|
if 'example_dialogue' in keyword: |
|
|
|
self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue']) |
|
|
|
if 'persona' in keyword: |
|
|
|
self.bot.extra_info['persona'].append(keyword['persona']) |
|
|
|
if 'scenario' in keyword: |
|
|
|
self.bot.extra_info['scenario'].append(keyword['scenario']) |
|
|
|
self.bot.keywords[i]["active"] -= 1 |
|
|
|
|
|
|
|
if self.bot.not_synced: |
|
|
|
return |
|
|
|