Пример #1
0
        public static async Task UpdateList(string name, string id, bool remove = true)
        {
            string guildpath = FileDirUtil.GetGuildDir(id);
            string namepath  = Path.Combine(guildpath, FileDirUtil.JSONNAMES);
            string livepath  = Path.Combine(guildpath, FileDirUtil.JSONLIVE);
            string idpath    = Path.Combine(guildpath, FileDirUtil.JSONIDS);

            List <string> names = JSONUtil.GetJsonToList <string>(namepath);
            Dictionary <string, string> live = JSONUtil.GetJsonToDic <string, string>(livepath);
            Dictionary <string, string> ids  = JSONUtil.GetJsonToDic <string, string>(idpath);

            if (remove)
            {
                names.Remove(name);
                live.Remove(name);
                ids.Remove(name);
                JSONUtil.WriteJsonToFile(names, namepath);

                JSONUtil.WriteJsonToFile(live, livepath);

                JSONUtil.WriteJsonToFile(ids, idpath);

                Console.WriteLine("updated name removal for " + name);
            }
        }
Пример #2
0
        public static async Task GetChannelIDs(string id, bool refresh = false)
        {
            string guildpath = FileDirUtil.GetGuildDir(id);
            string namepath  = Path.Combine(guildpath, FileDirUtil.JSONNAMES);
            string livepath  = Path.Combine(guildpath, FileDirUtil.JSONLIVE);
            string idpath    = Path.Combine(guildpath, FileDirUtil.JSONIDS);


            Console.WriteLine("getting channel ids");
            Dictionary <string, string> nameid = new Dictionary <string, string>();
            Dictionary <string, string> live   = JSONUtil.GetJsonToDic <string, string>(livepath);
            List <string> names        = JSONUtil.GetJsonToList <string>(namepath);
            string        searchstring = "tinietinie";

            if (names.Count > 1)
            {
                searchstring = string.Join("&login="******"users?login="******"Channels");

            Console.WriteLine("loginresponse" + response);
            JSONUtil.WriteJsonToFile(null, Path.Combine(guildpath, FileDirUtil.JSONUSERS), response);
            Console.WriteLine("written users to file");
            Users users = JsonConvert.DeserializeObject <Users>(response);

            Console.WriteLine("made user obj");
            foreach (User u in users.users)
            {
                Console.WriteLine("user: "******"is refresh");
                    if (!live.ContainsKey(u.name))
                    {
                        Console.WriteLine("new key");
                        live[u.name] = "offline";
                    }
                }
                else
                {
                    Console.WriteLine("not refresh, set to offline");
                    live[u.name] = "offline";
                }
            }

            JSONUtil.WriteJsonToFile(nameid, idpath);
            JSONUtil.WriteJsonToFile(live, livepath);
        }