Merge branch 'logictags'
This commit is contained in:
commit
32d430c8e5
|
@ -18,7 +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 this out.
|
`auth_msg` - The message to send to the `tracker_bot` to authenticate with and access the announce channel. It's up to you figure this out.
|
||||||
`watch_dir` - The directory to save torrents to.
|
`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.
|
`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.
|
`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. Tag inside of brackets are AND'd together, tag groups are then OR'd together. Tags starting with ! are treated as NOT [tag]. In the example below, announce messages with ['English' AND NOT 'Manga'] OR ['Manga' AND 'English' AND 'Archived'] OR 'Dual Language' OR 'Softsubs' will be matched.
|
||||||
`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.
|
`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
|
### Example config.cfg
|
||||||
|
@ -32,8 +32,12 @@ tracker_bot = Udon
|
||||||
auth_msg = BOT #oppaitime-announce iou1name SpaghettiIsAFaggot
|
auth_msg = BOT #oppaitime-announce iou1name SpaghettiIsAFaggot
|
||||||
watch_dir = /home/iou1name/torrent/oppaitime/Watch/
|
watch_dir = /home/iou1name/torrent/oppaitime/Watch/
|
||||||
cookies_txt = cookies.txt
|
cookies_txt = cookies.txt
|
||||||
|
<<<<<<< HEAD
|
||||||
tags = English,Dual Language,subs
|
tags = English,Dual Language,subs
|
||||||
blacklist = Loose
|
blacklist = Loose
|
||||||
|
=======
|
||||||
|
tags = [English,!Manga],[Manga,English,Archived],[Dual Language],[Softsubs]
|
||||||
|
>>>>>>> logictags
|
||||||
|
|
||||||
[redacted]
|
[redacted]
|
||||||
server = irc.scratch-network.net
|
server = irc.scratch-network.net
|
||||||
|
@ -44,5 +48,5 @@ tracker_bot = Drone
|
||||||
auth_msg = enter #red-announce iou1name TheyllAlwaysBePTHToMe
|
auth_msg = enter #red-announce iou1name TheyllAlwaysBePTHToMe
|
||||||
watch_dir = /home/iou1name/torrent/passtheheadphones/Watch/
|
watch_dir = /home/iou1name/torrent/passtheheadphones/Watch/
|
||||||
cookies_txt = cookies.txt
|
cookies_txt = cookies.txt
|
||||||
tags = rock,metal
|
tags = [rock]
|
||||||
```
|
```
|
||||||
|
|
16
oppaiBot.py
16
oppaiBot.py
|
@ -27,9 +27,12 @@ class OppaiBot(irc.IRCClient):
|
||||||
self.cj.load()
|
self.cj.load()
|
||||||
|
|
||||||
self.watch_dir = self.config["watch_dir"]
|
self.watch_dir = self.config["watch_dir"]
|
||||||
self.tags = self.config["tags"].split(",")
|
|
||||||
|
self.tags = re.findall(r"\[(.+?)\]", self.config["tags"])
|
||||||
|
self.tags = [tag.split(",") for tag in self.tags]
|
||||||
self.blacklist = self.config.get("blacklist").split(",")
|
self.blacklist = self.config.get("blacklist").split(",")
|
||||||
|
|
||||||
|
|
||||||
def save_torrent(self, url, directory):
|
def save_torrent(self, url, directory):
|
||||||
"""
|
"""
|
||||||
Downloads and saves the torrent file to the given directory.
|
Downloads and saves the torrent file to the given directory.
|
||||||
|
@ -55,7 +58,16 @@ class OppaiBot(irc.IRCClient):
|
||||||
if any(black_in_msg):
|
if any(black_in_msg):
|
||||||
return
|
return
|
||||||
|
|
||||||
tags_in_msg = [tag in message for tag in self.tags]
|
tags_in_msg = []
|
||||||
|
for tag_group in self.tags:
|
||||||
|
tags_in_group = []
|
||||||
|
for tag in tag_group:
|
||||||
|
if tag.startswith("!"):
|
||||||
|
tags_in_group.append(tag[1:] not in message)
|
||||||
|
else:
|
||||||
|
tags_in_group.append(tag in message)
|
||||||
|
tags_in_msg.append(all(tags_in_group))
|
||||||
|
|
||||||
if any(tags_in_msg):
|
if any(tags_in_msg):
|
||||||
url = re.findall(r"(http.+?) ", message)[1]
|
url = re.findall(r"(http.+?) ", message)[1]
|
||||||
self.save_torrent(url, self.watch_dir)
|
self.save_torrent(url, self.watch_dir)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user