Made categories mandatory for add and search, updated help
This commit is contained in:
parent
71b970e68a
commit
46d096eeeb
34
bot.py
34
bot.py
|
@ -300,12 +300,11 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += self.api_caller.torrentList("full")
|
message += self.api_caller.torrentList("full")
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
category = "unknown"
|
category = tokens[2]
|
||||||
string_start = 2
|
if category not in ["all", "anime", "games", "movies", "music", "software", "tv"]:
|
||||||
if tokens[2].startswith("c="):
|
message = "Please specify a category"
|
||||||
category = tokens[2].removeprefix("c=")
|
else:
|
||||||
string_start = 3
|
string_start = 3
|
||||||
|
|
||||||
message += self.api_caller.add(tokens[string_start], msg['mucnick'], category)
|
message += self.api_caller.add(tokens[string_start], msg['mucnick'], category)
|
||||||
|
|
||||||
case "searchplugins":
|
case "searchplugins":
|
||||||
|
@ -323,11 +322,14 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += "\n```"
|
message += "\n```"
|
||||||
|
|
||||||
case "search":
|
case "search":
|
||||||
category = "all"
|
if len(tokens) < 4:
|
||||||
search_token_start=2
|
message = "Please specify a category and search term"
|
||||||
if tokens[2].startswith("c="):
|
else:
|
||||||
category = tokens[2].removeprefix("c=")
|
category = tokens[2]
|
||||||
search_token_start=3
|
if category not in ["all", "anime", "games", "movies", "music", "software", "tv"]:
|
||||||
|
message = "Invalid category: " + category
|
||||||
|
else:
|
||||||
|
search_token_start = 3 # qb search CATEGORY ...
|
||||||
search_string = " ".join(tokens[search_token_start:])
|
search_string = " ".join(tokens[search_token_start:])
|
||||||
resp = self.api_caller.search_start(search_string, category)
|
resp = self.api_caller.search_start(search_string, category)
|
||||||
if resp.status_code == 409:
|
if resp.status_code == 409:
|
||||||
|
@ -355,7 +357,7 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
the_list = [i for i in the_list if int(i[2]) != 0]
|
the_list = [i for i in the_list if int(i[2]) != 0]
|
||||||
|
|
||||||
# Report the number of torrents in the search results
|
# Report the number of torrents in the search results
|
||||||
message += "Total results for \"" + search_string + "\": " + str(len(the_list)) + "\n"
|
message += "Total results for \"" + search_string + "\" under category " + category + ": " + str(len(the_list)) + "\n"
|
||||||
|
|
||||||
message += "\n".join([str(i) + ". " + l[0] + ", "
|
message += "\n".join([str(i) + ". " + l[0] + ", "
|
||||||
"seeds: " + str(l[2]) + ", "
|
"seeds: " + str(l[2]) + ", "
|
||||||
|
@ -384,10 +386,10 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
case "searchhelp":
|
case "searchhelp":
|
||||||
message += "Conducting a search\n"
|
message += "Conducting a search\n"
|
||||||
message += "-------------------\n"
|
message += "-------------------\n"
|
||||||
message += "The whole search process is done with 2 commands.\n First, `search` is used to obtain a list of results.\n The optional `c=CATEGORY` selects a category, by default it is \"all\".\n The full list of categories can be obtained from `searchplugins`, 3rd column.\n Note that only enabled plugins are utilized by this feature.\n I highly recommend using a category, or the search can take a really long time.\n Once the search process concludes (it takes at most 30 seconds), you will receive a list of indices, along with names, number of seeders, and file size.\n Once you choose the torrent you want, note the index and invoke `searchselect INDEX`.\n This will add the torrent to the queue.\n The following is an example usage of the search functionality.\n"
|
message += "The whole search process is done with 2 commands.\n First, `search` is used to obtain a list of results.\n The required CATEGORY selects a category.\n The full list of categories can be obtained from `searchplugins`, 3rd column.\n Note that only enabled plugins are utilized by this feature.\n Once the search process concludes (it takes at most 30 seconds), you will receive a list of indices, along with names, number of seeders, and file size.\n Once you choose the torrent you want, note the index and invoke `searchselect INDEX`.\n This will add the torrent to the queue.\n The following is an example usage of the search functionality.\n"
|
||||||
message += "```\n"
|
message += "```\n"
|
||||||
message += self.nick + " search c=software ubuntu 16.04\n\n"
|
message += self.nick + " search software ubuntu 16.04\n\n"
|
||||||
message += "Total results for \"ubuntu 16.04\": 18\n"
|
message += "Total results for \"ubuntu 16.04\" in category software: 18\n"
|
||||||
message += "0. Ubuntu MATE 16.04.2 [MATE][armhf][img.xz][Uzerus], seeds: 260, size: 1.10 GB\n"
|
message += "0. Ubuntu MATE 16.04.2 [MATE][armhf][img.xz][Uzerus], seeds: 260, size: 1.10 GB\n"
|
||||||
message += "1. Ubuntu 16.04.1 LTS Desktop 64-bit, seeds: 55, size: 1.40 GB\n"
|
message += "1. Ubuntu 16.04.1 LTS Desktop 64-bit, seeds: 55, size: 1.40 GB\n"
|
||||||
message += "2. Ubuntu 16.04.5 LTS [Xenial Xerus][Unity][x64 x86_64 amd64][Server][ISO][Uzerus], seeds: 8, size: 0.60 GB\n"
|
message += "2. Ubuntu 16.04.5 LTS [Xenial Xerus][Unity][x64 x86_64 amd64][Server][ISO][Uzerus], seeds: 8, size: 0.60 GB\n"
|
||||||
|
@ -406,9 +408,9 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += "help: Displays this help" + "\n"
|
message += "help: Displays this help" + "\n"
|
||||||
message += "list: Lists torrents, names truncated to 25 characters\n"
|
message += "list: Lists torrents, names truncated to 25 characters\n"
|
||||||
message += "fulllist: Lists torrents, no name truncation\n"
|
message += "fulllist: Lists torrents, no name truncation\n"
|
||||||
message += "add [c=CATEGORY] MAGNET_URL: Adds torrent corresponding to MAGNET_URL to the download list.\n\tNote that this will take about 5 seconds, as there's a check for 0 seeds after 5 seconds as a warning.\n\tOptionally include CATEGORY to assist in automated copy.\n\tValid CATEGORY values can be found with the categories in searchplugins\n"
|
message += "add CATEGORY MAGNET_URL: Adds torrent corresponding to MAGNET_URL to the download list with category CATEGORY.\n\tNote that this will take about 5 seconds, as there's a check for 0 seeds after 5 seconds as a warning.\n\tValid CATEGORY values can be found with the searchplugins command.\n"
|
||||||
message += "searchplugins: List the installed search plugins\n"
|
message += "searchplugins: List the installed search plugins\n"
|
||||||
message += "search [c=CATEGORY] search_string: Search from all enabled plugins for search_string, with optional category CATEGORY. Valid categories can be found from the searchplugins command.\n"
|
message += "search CATEGORY SEARCH_STRING: Search from all enabled plugins for SEARCH_STRING in CATEGORY. Valid CATEGORY values can be found from the searchplugins command.\n"
|
||||||
message += "searchselect: Selects a torrent from a previous search to download\n"
|
message += "searchselect: Selects a torrent from a previous search to download\n"
|
||||||
message += "searchhelp: Shows the in-depth process of utilizing search"
|
message += "searchhelp: Shows the in-depth process of utilizing search"
|
||||||
message += "\n```"
|
message += "\n```"
|
||||||
|
|
Loading…
Reference in New Issue