Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
-> one match
Browse files
app.py
CHANGED
|
@@ -99,13 +99,14 @@ def extract_adjacent_words(content, trigger):
|
|
| 99 |
pattern = r'\b' + r'\b\s*\b'.join(map(re.escape, trigger)) + r'\b'
|
| 100 |
regex = re.compile(pattern, re.IGNORECASE)
|
| 101 |
|
| 102 |
-
|
|
|
|
| 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
|
|
|
|
| 99 |
pattern = r'\b' + r'\b\s*\b'.join(map(re.escape, trigger)) + r'\b'
|
| 100 |
regex = re.compile(pattern, re.IGNORECASE)
|
| 101 |
|
| 102 |
+
match = regex.search(content)
|
| 103 |
+
if match:
|
| 104 |
start, end = match.span()
|
| 105 |
before = content[:start].split()[-5:]
|
| 106 |
after = content[end:].split()[:5]
|
| 107 |
+
print("--------------------------------------------------------------")
|
| 108 |
print('...' + ' '.join(before + [match.group()] + after) + '...')
|
| 109 |
return '...' + ' '.join(before + [match.group()] + after) + '...'
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
@bot.event
|