Add support for \ and ¡¡
This commit is contained in:
parent
aec546e372
commit
98124aeb42
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import re
|
||||
|
||||
from nio import (
|
||||
AsyncClient,
|
||||
|
@ -62,7 +63,7 @@ class Callbacks:
|
|||
|
||||
has_jerryxiao_prefix = False
|
||||
for i in msg.splitlines():
|
||||
if i.startswith("/") or i.startswith("!!"):
|
||||
if re.match("^(!!|\\\\|/|¡¡)", i):
|
||||
has_jerryxiao_prefix = True
|
||||
msg = i
|
||||
break
|
||||
|
@ -72,6 +73,14 @@ class Callbacks:
|
|||
await send_jerryxiao(self.client, room, event, "/", reply_to, msg)
|
||||
elif msg.startswith("!!"):
|
||||
await send_jerryxiao(self.client, room, event, "!!", reply_to, msg)
|
||||
if msg.startswith("\\"):
|
||||
await send_jerryxiao(
|
||||
self.client, room, event, "\\", reply_to, msg, True
|
||||
)
|
||||
elif msg.startswith("¡¡"):
|
||||
await send_jerryxiao(
|
||||
self.client, room, event, "¡¡", reply_to, msg, True
|
||||
)
|
||||
|
||||
# # Treat it as a command only if it has a prefix
|
||||
# if has_command_prefix:
|
||||
|
|
|
@ -131,12 +131,18 @@ async def send_jerryxiao(
|
|||
prefix: str,
|
||||
reply_to: str,
|
||||
reference_text: str,
|
||||
reversed_senders: bool = False,
|
||||
):
|
||||
from_sender = event.sender
|
||||
target_event = await client.room_get_event(room.room_id, reply_to)
|
||||
to_sender = target_event.event.sender
|
||||
action = reference_text[len(prefix) :]
|
||||
if action != "":
|
||||
if reversed_senders:
|
||||
# Swap from and to
|
||||
_tmp = from_sender
|
||||
from_sender = to_sender
|
||||
to_sender = _tmp
|
||||
send_text_formatted = make_jerryxiao_reply(from_sender, to_sender, action, room)
|
||||
send_text = (
|
||||
f"{room.user_name(from_sender)} {action}了 {room.user_name(to_sender)}"
|
||||
|
|
Loading…
Reference in a new issue