Update app.py
Browse files
app.py
CHANGED
@@ -95,19 +95,17 @@ async def on_message(message):
|
|
95 |
|
96 |
|
97 |
def extract_adjacent_words(content, trigger):
|
98 |
-
|
99 |
-
|
|
|
100 |
|
101 |
-
|
102 |
start, end = match.span()
|
103 |
-
before = content[:start].
|
104 |
-
after = content[end:].
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
output = f"...{context_before} + {match.group()} + {context_after}..."
|
110 |
-
return output
|
111 |
|
112 |
|
113 |
@bot.event
|
|
|
95 |
|
96 |
|
97 |
def extract_adjacent_words(content, trigger):
|
98 |
+
words = content.split()
|
99 |
+
pattern = r'\b' + r'\b\s*\b'.join(map(re.escape, trigger)) + r'\b'
|
100 |
+
regex = re.compile(pattern, re.IGNORECASE)
|
101 |
|
102 |
+
for match in regex.finditer(content):
|
103 |
start, end = match.span()
|
104 |
+
before = content[:start].split()[-5:]
|
105 |
+
after = content[end:].split()[:5]
|
106 |
+
print('...' + ' '.join(before + [match.group()] + after) + '...')
|
107 |
+
return '...' + ' '.join(before + [match.group()] + after) + '...'
|
108 |
+
return content
|
|
|
|
|
|
|
109 |
|
110 |
|
111 |
@bot.event
|