Open jiegen78 opened 2 years ago
Advanced features require a little knowledge of regex basics. The keyword exclusion function can be arranged at leisure 😁
i am not a regex expert but i digged the internet for a few hours for a regex "with js syntax" and found nothing working. can you kindly make me an example of the syntax? if I put /this is a sentence/ig does not work. thanks a lot
i am not a regex expert but i digged the internet for a few hours for a regex "with js syntax" and found nothing working. can you kindly make me an example of the syntax? if I put /this is a sentence/ig does not work. thanks a lot
try it.
/^\s*this is a sentence\s*$/ig
thanks for the example, it works on a regex test site, but if I put in the bot the command /subscribe /\ssentence with spaces\s/ig the command is not accepted (also with ^ and $ ) it looks like the bot uses space as a separator and does not read correctly the command after the first space, resulting into an incomplete command.
thanks for the example, it works on a regex test site,
but if I put in the bot the command /subscribe /\ssentence with spaces\s/ig the command is not accepted (also with ^ and $ )
it looks like the bot uses space as a separator and does not read correctly the command after the first space, resulting into an incomplete command.
yep. Spaces are indeed separators. I need to see the full command you entered. It may need to be fixed
you can consider "/subscribe /\ssentence with spaces\s/i testchannel" as a non-specific copy of my command, I have not used ^ and $ because the sentence with spaces is part of the whole message I have to filter.
thanks a lot.
Sorry, the use of spaces does have a bug.
You can temporarily replace spaces with \s
example:
/subscribe /\bsentencs\s+with\s+spaces\b/i test-channel
this works, thanks a lot
an alternative I'm using is to allow the "+" to be used as a separator, it's simpler than using regular expressions. so:
/subscribe sentence+with+space test-channel
diff --git a/main.py b/main.py
index b53a257..4a23218 100644
--- a/main.py
+++ b/main.py
@@ -288,6 +288,7 @@ where ({' OR '.join(condition_strs)}) and l.status = 0 order by l.create_time
else:
logger.debug(f'regex_match empty. regex:{keywords} ,message: t.me/{event_chat_username}/{event.message.id}')
else:# Normal mode
+ keywords = keywords.replace('+', ' ')
if keywords in text:
# # {chat_title} \n\n
channel_title = f"\n\nCHANNEL: {chat_title}" if not event_chat_username else ""
is it possible to keyword a whole sentence? or, is it possible to make a filter "word 1 but not word 2" i.e. send notification if there is only word 1 but not word 2
thanks