Compare commits

...

2 Commits

2 changed files with 7 additions and 4 deletions

2
bot.py
View File

@ -91,7 +91,7 @@ class Bot:
candidates.append(reply)
print("Accepting reply.")
reply = max(candidates, key=utils.reply_length)
reply = max(candidates, key=lambda r: min(utils.reply_length(r, 500)))
self.client.reply(reply, comment)

View File

@ -44,10 +44,13 @@ def remove_notifications(text):
"soren",
]
def replace(match):
# Insert <i></i> after the first character of the matched string.
user = match.group()
return f"{user[:1]}<i></i>{user[1:]}"
for user in notified_users:
match = re.search(user, text, re.IGNORECASE)
if match:
text = f"{text[:match.start() + 1]}<i></i>{text[match.start() + 1:]}"
text = re.sub(user, replace, text, flags=re.IGNORECASE)
return text