Compare commits
2 Commits
ea0b22b5ec
...
71b3ab2bf6
Author | SHA1 | Date |
---|---|---|
float-trip | 71b3ab2bf6 | |
float-trip | f5c7ac30f7 |
2
bot.py
2
bot.py
|
@ -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)
|
||||
|
||||
|
||||
|
|
9
utils.py
9
utils.py
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue