Skip to content
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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

reyasmohammed
Copy link

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.

@NotAFile
Copy link
Collaborator

Awesome! Thanks for your work. Since this is not shipping quality yet as you noted, I will mark this as WIP.

@NotAFile NotAFile changed the title Included Blacklist option WIP: Included Blacklist option Nov 15, 2017
@RememberTheAir
Copy link
Member

RememberTheAir commented Nov 15, 2017

@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:
*a link is posted*
If the antispam is on: check if the link is whitelisted. If yes, ignore; if not, delete/warn/punish.
If the antispam is off: check if the link is blacklisted. If yes, delete/warn/punish; if not, ignore

I think this would be the most logical solution

@reyasmohammed
Copy link
Author

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.

Copy link
Member

@yangm97 yangm97 left a 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)
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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.

@yangm97 yangm97 changed the base branch from master to develop September 29, 2018 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants