Esempio n. 1
0
        public async Task RSSRemoveAllSources()
        {
            List <string> torrents = Extensions.readFile(Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));

            foreach (string source in torrents)
            {
                if (!RSSTorrentUtility.qBitTorrentRemoveSource(source))
                {
                    await ReplyAsync("``There was an issue updating the qBitTorrent autodownload config. Please check it manually.``").ConfigureAwait(false);

                    return;
                }
            }

            List <string> temp = new List <string>();

            Extensions.writeLinesToFile(temp, Path.GetFullPath(Resources.general_sources, Extensions.config_values.root_path));
            Extensions.writeLinesToFile(temp, Path.GetFullPath(Resources.manga_sources, Extensions.config_values.root_path));
            Extensions.writeLinesToFile(temp, Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));
            RSSfeed.RSSRefresh();

            await ReplyAsync("``All the RSS sources were removed.``").ConfigureAwait(false);

            RSSTorrentUtility.qBittorrentRestart();
        }
Esempio n. 2
0
        public async Task RSSAddTorrentSource([Remainder] string query)
        {
            string input = query.TrimStart(' ').TrimEnd(' ');

            if (!input.Contains(" "))
            {
                List <string> current = Extensions.readFile(Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));
                if (!current.Contains(input))
                {
                    current.Add(input);
                    if (RSSTorrentUtility.qBitTorrentAddSource(input))
                    {
                        Extensions.writeLinesToFile(current, Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));
                        RSSfeed.RSSRefresh();
                        await ReplyAsync("``A new RSS source has been added.``").ConfigureAwait(false);

                        RSSTorrentUtility.qBittorrentRestart();
                    }
                    else
                    {
                        await ReplyAsync("``There was an issue updating the qBitTorrent autodownload config.``").ConfigureAwait(false);
                    }
                }
                else
                {
                    await ReplyAsync("``The source you tried to add is already registered.``").ConfigureAwait(false);
                }
            }
            else
            {
                await ReplyAsync("``The source you tried to add is in an invalid format. (Make sure it has no spaces.)``").ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        public async Task RSSRemoveall([Remainder] string query = "a")
        {
            string resource;

            if (query.Equals("a"))
            {
                resource = Path.GetFullPath(Resources.anime_filters, Extensions.config_values.root_path);
                List <string> filters = Extensions.readFile(resource);
                if (!RSSTorrentUtility.qBitTorrentRemoveFilter(filters.ToArray()))
                {
                    await ReplyAsync("``There was an issue updating the qBitTorrent autodownload config. Please check it manually.``").ConfigureAwait(false);
                }
            }
            else if (query.Equals("m"))
            {
                resource = Path.GetFullPath(Resources.manga_filters, Extensions.config_values.root_path);
            }
            else
            {
                resource = Path.GetFullPath(Resources.anime_filters, Extensions.config_values.root_path);
            }

            List <string> temp = new List <string>();

            Extensions.writeLinesToFile(temp, resource);
            RSSfeed.RSSRefresh();
            await ReplyAsync("``The RSS filter is now empty.``").ConfigureAwait(false);

            RSSTorrentUtility.qBittorrentRestart();
        }
Esempio n. 4
0
        public async Task RSSRemoveSource([Remainder] string query)
        {
            string input = query.TrimStart(' ').TrimEnd(' ');

            if (!input.Contains(" "))
            {
                List <string> general  = Extensions.readFile(Path.GetFullPath(Resources.general_sources, Extensions.config_values.root_path));
                List <string> manga    = Extensions.readFile(Path.GetFullPath(Resources.manga_sources, Extensions.config_values.root_path));
                List <string> torrents = Extensions.readFile(Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));
                if (manga.Remove(input) || torrents.Remove(input) || general.Remove(input))
                {
                    Extensions.writeLinesToFile(general, Path.GetFullPath(Resources.general_sources, Extensions.config_values.root_path));
                    Extensions.writeLinesToFile(manga, Path.GetFullPath(Resources.manga_sources, Extensions.config_values.root_path));
                    if (RSSTorrentUtility.qBitTorrentRemoveSource(input))
                    {
                        Extensions.writeLinesToFile(torrents, Path.GetFullPath(Resources.anime_sources, Extensions.config_values.root_path));
                        RSSfeed.RSSRefresh();
                        await ReplyAsync("``The specified RSS source has been removed.``").ConfigureAwait(false);

                        RSSTorrentUtility.qBittorrentRestart();
                    }
                    else
                    {
                        await ReplyAsync("``There was an issue updating the qBitTorrent autodownload config.``").ConfigureAwait(false);
                    }
                }
                else
                {
                    await ReplyAsync("``The source you tried to remove isn't registered.``").ConfigureAwait(false);
                }
            }
            else
            {
                await ReplyAsync("``The source you tried to remove is in an invalid format. (Make sure it has no spaces.)``").ConfigureAwait(false);
            }
        }
Esempio n. 5
0
        public async Task RSSAddGeneralSource([Remainder] string query)
        {
            string input = query.TrimStart(' ').TrimEnd(' ');

            if (!input.Contains(" "))
            {
                List <string> current = Extensions.readFile(Path.GetFullPath(Resources.general_sources, Extensions.config_values.root_path));
                if (!current.Contains(input))
                {
                    current.Add(input);
                    Extensions.writeLinesToFile(current, Path.GetFullPath(Resources.general_sources, Extensions.config_values.root_path));
                    RSSfeed.RSSRefresh();
                    await ReplyAsync("``A new RSS source has been added.``").ConfigureAwait(false);
                }
                else
                {
                    await ReplyAsync("``The source you tried to add is already registered.``").ConfigureAwait(false);
                }
            }
            else
            {
                await ReplyAsync("``The source you tried to add is in an invalid format. (Make sure it has no spaces.)``").ConfigureAwait(false);
            }
        }
Esempio n. 6
0
        public async Task RSSAdd([Remainder] string query)
        {
            string[]      items    = query.Split(new[] { "|" }, 2, StringSplitOptions.RemoveEmptyEntries);
            string[]      filters  = items[0].TrimEnd(' ').Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            List <string> existing = new List <string>();

            string mode;
            string resource;

            if (filters[0].Substring(0, 2).Equals("a "))
            {
                resource   = Path.GetFullPath(Resources.anime_filters, Extensions.config_values.root_path);
                mode       = filters[0].Substring(0, 1);
                filters[0] = filters[0].Substring(2);
            }
            else if (filters[0].Substring(0, 2).Equals("m "))
            {
                resource   = Path.GetFullPath(Resources.manga_filters, Extensions.config_values.root_path);
                mode       = filters[0].Substring(0, 1);
                filters[0] = filters[0].Substring(2);
            }
            else
            {
                resource = Path.GetFullPath(Resources.anime_filters, Extensions.config_values.root_path);
                mode     = "a";
            }

            List <string> current = Extensions.readFile(resource);

            foreach (string unparsed in filters)
            {
                string input = unparsed.TrimStart(' ').ToLower();
                if (current.Contains(input))
                {
                    existing.Add(input);
                }
                else
                {
                    current.Add(input);
                }
            }
            if (existing.Count < filters.Length)
            {
                if (existing.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var wrong in existing)
                    {
                        sb.Append(", " + wrong);
                    }
                    await ReplyAsync("``" + sb.ToString().Substring(2) + (existing.Count == 1 ? " is " : " are ") + "already registered.``").ConfigureAwait(false);
                }
                if (mode == "a")
                {
                    if (RSSTorrentUtility.qBitTorrentAddFilter(filters))
                    {
                        Extensions.writeLinesToFile(current, resource);
                        RSSfeed.RSSRefresh();
                        await ReplyAsync("``The RSS filter has been updated.``").ConfigureAwait(false);

                        RSSTorrentUtility.qBittorrentRestart();
                    }
                    else
                    {
                        await ReplyAsync("``There was an issue updating the qBitTorrent autodownload config.``").ConfigureAwait(false);
                    }
                }
                else
                {
                    Extensions.writeLinesToFile(current, resource);
                    RSSfeed.RSSRefresh();
                    await ReplyAsync("``The RSS filter has been updated.``").ConfigureAwait(false);
                }
            }
            else
            {
                await ReplyAsync("``All the filters you tried to add already exist.``").ConfigureAwait(false);
            }

            if (items.Length == 2 && items[1].TrimStart(' ').Equals("s"))
            {
                await RSSShow(mode);
            }
        }