added blacklist

This commit is contained in:
iou1name 2018-05-17 13:44:22 -04:00
parent cb68972816
commit 233579e765
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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]