Skip to content

Commit

Permalink
further fixes to emoji regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkessel committed Mar 15, 2024
1 parent 751d41d commit 935b131
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion maubot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.rosi-kessel.reacjibot
version: 2.7.9
version: 2.7.12
license: MIT
modules:
- reacjibot
Expand Down
10 changes: 5 additions & 5 deletions reacjibot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from maubot import Plugin, MessageEvent
from maubot.handlers import command, event

EMOJI=re.compile('(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+', flags=re.UNICODE)

class Config(BaseProxyConfig):
def do_update(self, helper: ConfigUpdateHelper) -> None:
helper.copy("debug")
Expand Down Expand Up @@ -113,7 +115,7 @@ async def on_external_config_update(self) -> None:
await self.start()

# generic_react: called when a reaction to a message event occurs; main guts of the plugin
@command.passive(regex=re.compile('(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+', flags=re.UNICODE), field=lambda evt: evt.content.relates_to.key, event_type=EventType.REACTION, msgtypes=None)
@command.passive(regex=EMOJI, field=lambda evt: evt.content.relates_to.key, event_type=EventType.REACTION, msgtypes=None)
async def generic_react(self, evt: ReactionEvent, key: Tuple[str]) -> None:
if self.restrict and evt.sender not in self.allowed:
self.debug and self.log.debug(f"user {evt.sender} not allowed to cross-post")
Expand Down Expand Up @@ -221,9 +223,8 @@ async def map(self, evt: MessageEvent, mapping: str) -> None:
return
try:
x = mapping.split(" ")
re_emoji = re.compile('[\U00010000-\U0010ffff]+', flags=re.UNICODE)
re_html = re.compile(r'<.*?>')
emoji = re_emoji.findall(x[0])
emoji = EMOJI.findall(x[0])
room_candidate = re_html.sub('',x[1])
room = await self.MapRoom(room_candidate)
xroom = str(MatrixURI.build(room))
Expand All @@ -247,8 +248,7 @@ async def delete(self, evt: MessageEvent, mapping: str) -> None:
return
try:
x = mapping.split(" ")
re_emoji = re.compile('[\U00010000-\U0010ffff]+', flags=re.UNICODE)
emoji = re_emoji.findall(x[0])
emoji = EMOJI.findall(x[0])
finally:
if not emoji:
await evt.reply(f"error, invalid delete command {mapping}")
Expand Down

0 comments on commit 935b131

Please sign in to comment.