From 233579e765b3b8f6269b4b099266901ab1ae17bc Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 17 May 2018 13:44:22 -0400 Subject: [PATCH] added blacklist --- README.md | 4 +++- oppaiBot.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71ec3cb..1a56074 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Python modules: `requests, twisted` `watch_dir` - The directory to save torrents to. `cookies_txt` - The path to where your session cookie(s) are stored. Should be in Netscape format. `tags` - Comma-delineated list of tags to look for in each announce message. The script is just performing simple string comparisons on the entire message, so the 'tag' can be any substring appearing in the announce message. Note that this is essentially an OR operation. I'm too lazy to get more complex than that. +`blacklist` - Comma-delineated list of blacklisted tags. Same as `tags`, except if any of these are found in the announce message the bot skips the entire message. This parameter is optional. ### Example config.cfg ``` @@ -31,7 +32,8 @@ tracker_bot = Udon auth_msg = BOT #oppaitime-announce iou1name SpaghettiIsAFaggot watch_dir = /home/iou1name/torrent/oppaitime/Watch/ cookies_txt = cookies.txt -tags = English,Dual Language +tags = English,Dual Language,subs +blacklist = Loose [redacted] server = irc.scratch-network.net diff --git a/oppaiBot.py b/oppaiBot.py index a4c8f3c..1000a2a 100755 --- a/oppaiBot.py +++ b/oppaiBot.py @@ -28,7 +28,7 @@ class OppaiBot(irc.IRCClient): self.watch_dir = self.config["watch_dir"] self.tags = self.config["tags"].split(",") - + self.blacklist = self.config.get("blacklist").split(",") def save_torrent(self, url, directory): """ @@ -51,6 +51,10 @@ class OppaiBot(irc.IRCClient): or users alike. """ # More advanced logic is left as an exercise to the reader. + black_in_msg = [tag in message for tag in self.blacklist] + if any(black_in_msg): + return + tags_in_msg = [tag in message for tag in self.tags] if any(tags_in_msg): url = re.findall(r"(http.+?) ", message)[1]