-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Included Blacklist option #252
base: develop
Are you sure you want to change the base?
Conversation
Awesome! Thanks for your work. Since this is not shipping quality yet as you noted, I will mark this as WIP. |
@reyasmohammed looks good so far. I'm just not sure how the bot should behave if a blacklisted link is posted - brutally deleting it is cool but there should be some sort of "punishment" similar to how the antispam handles repeated spam messages (ban/kick/restrict the user). Maybe blacklisted links should be deleted & the user punished only when the antispam is off, but the bot will act as if it was on Eg: I think this would be the most logical solution |
I have initially written like that, then I have changed as per requirement from the Group which I had this clone running. I have the code with me, will include once I am back from my trip. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once merge conflicts and review comments are solved this should be ready to go.
@@ -67,6 +67,18 @@ local function is_whitelisted(chat_id, text) | |||
end | |||
end | |||
|
|||
local function is_blacklisted(chat_id, text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could've generalized the whitelist function and share some code between the two.
@@ -372,6 +372,73 @@ function plugin.onTextMessage(msg, blocks) | |||
db:srem(('chat:%d:whitelist'):format(msg.chat.id), blocks[2]) | |||
api.sendReply(msg, 'Done') | |||
end | |||
|
|||
if (blocks[1] == 'bl' or blocks[1] == 'blacklist') and blocks[2] then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this.
if (blocks[1] == 'bl' or blocks[1] == 'blacklist') and not blocks[2] then | ||
local links = db:smembers(('chat:%d:blacklist'):format(msg.chat.id)) | ||
if not next(links) then | ||
api.sendReply(msg, i18n("_The blacklist is empty_.\nUse `/bl [links]` to add some links to the blacklist"), true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use msg:send_reply() instead.
I have manually included changes which I have already done on my own Clone running personally. No translations included. I didnt log the delete action, as I am using the telegram feature of recent actions to identify at present. Also the blacklist is not checked in Antispam, it is direct option for every message.
Share your comments, so that I can improve the code if required.