mirror of
https://github.com/maubot/rss.git
synced 2025-03-14 19:16:35 -04:00
fix regex matching
This commit is contained in:
parent
5363e242d9
commit
748294c5af
10
rss/bot.py
10
rss/bot.py
@ -118,14 +118,12 @@ class RSSBot(Plugin):
|
||||
**attr.asdict(entry),
|
||||
}
|
||||
)
|
||||
entrytext = ' '.join(attr.asdict(entry).values())
|
||||
self.log.info(f"obtained entry text: {entrytext}")
|
||||
entrytext = ' '.join([str(value) for value in attr.asdict(entry).values()])
|
||||
|
||||
for match in re.finditer(r'\{\{ ([^}]*) \}\}', message):
|
||||
value = re.search(match.groups(0), entrytext)
|
||||
self.log.info(f"found match: {match} with regex {match.groups(0)} matching {value} in entrytext")
|
||||
message = message[:match.span()[0]] + value + message[match.span()[1]:]
|
||||
|
||||
value = re.search(re.compile(match.groups(0)[0]), entrytext)
|
||||
message = message[:match.span()[0]] + (value.group(0) if value is not None else "") + message[match.span()[1]:]
|
||||
|
||||
msgtype = MessageType.NOTICE if sub.send_notice else MessageType.TEXT
|
||||
msgchunks = [message[i:i + 30000] for i in range(0, len(message), 30000)]
|
||||
self.log.debug(f"Message length: {len(message)} Content length: {len(entry.content)} Chunks: {len(msgchunks)}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user