configurable tags

This commit is contained in:
iou1name 2018-05-09 18:25:07 -04:00
parent fbb554f198
commit 3fd1e9db7b
2 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ Python modules: `requests, twisted`
`auth_msg` - The message to send to the `tracker_bot` to authenticate with and access the announce channel. It's up to you figure it out.
`watch_dir` - The directory to save torrents to.
`cookies_txt` - The path to where you session cookie is 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, so the 'tag' can be any substring appearing in the announce message.
### Example config.cfg
```
@ -30,4 +31,5 @@ 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
```

View File

@ -26,6 +26,7 @@ class OppaiBot(irc.IRCClient):
self.cj.load()
self.watch_dir = self.config["watch_dir"]
self.tags = self.config["tags"].split(",")
def save_torrent(self, url, directory):
@ -48,7 +49,8 @@ class OppaiBot(irc.IRCClient):
or users alike.
"""
# More advanced logic is left as an exercise to the reader.
if "English" in message or "Dual Language" in message:
tags_in_msg = [tag in message for tag in self.tags]
if any(tags_in_msg):
url = message.split(" - ")[1].split(" / ")[1]
self.save_torrent(url, self.watch_dir)