Example #1
0
 private static void Client_OnWhisperReceived(object sender, OnWhisperReceivedArgs e)
 {
     if (e.WhisperMessage.Username == CurrentChannel || BotTools.ReadFromJson <List <string> >("resources\\moderators").Contains(e.WhisperMessage.Username))
     {
         BotTools.LogLine($"○ {e.WhisperMessage.DisplayName}: {e.WhisperMessage.Message.Trim()}");
     }
 }
Example #2
0
        private void OnTimer2MinTick(object sender, EventArgs e)
        {
            var posts = Instagram.GetPosts();

            if (posts.Count > 0)
            {
                bool petsExist = File.Exists($"{BotTools.BasePath}\\resources\\raz_pets.json");
                var  pastPets  = petsExist ? BotTools.ReadFromJson <List <string> >("resources\\raz_pets") : new List <string>();

                try
                {
                    var newPets = posts.Where(p => !pastPets.Contains(p["permalink"]));
                    if (newPets.Count() > 0)
                    {
                        foreach (var post in newPets)
                        {
                            BotTools.LogLine($"Saw new Raz pet -> {post["permalink"]}");
                            DiscordBot.PostToPetsChannel(post);
                            pastPets.Add(post["permalink"]);

                            using (var webClient = new System.Net.WebClient())
                            {
                                webClient.DownloadFile(post["media_url"], $"{BotTools.BasePath}\\datasources\\raz.jpg");
                            }
                        }
                        BotTools.WriteToJson(pastPets, "resources\\raz_pets");
                    }
                }
                catch (Exception petsException)
                {
                    BotTools.LogToSessionLogFile(petsException.ToString());
                    BotTools.LogLine("There was a problem loading past Raz Pets! See the session log for details.");
                }
            }
        }
Example #3
0
        public static void FilesInit()
        {
            if (File.Exists($"{BasePath}\\resources\\bot_settings.json"))
            {
                Settings = BotTools.ReadFromJson <Dictionary <string, dynamic> >("resources\\bot_settings");
            }
            else
            {
                string json     = Properties.Resources.bot_options;
                var    settings = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(json);
                Settings = settings;
                WriteToJson(Settings, "resources\\bot_settings");
            }

            if (!File.Exists($"{BasePath}\\resources\\builds.json"))
            {
                string buildsJson = Properties.Resources.builds;
                var    builds     = JsonConvert.DeserializeObject <Dictionary <string, string> >(buildsJson);
                WriteToJson(builds, "resources\\builds");
            }

            if (!File.Exists($"{BasePath}\\resources\\custom_commands.json"))
            {
                string customCommandsJson = Properties.Resources.custom_commands;
                var    customCommands     = JsonConvert.DeserializeObject <Dictionary <string, string> >(customCommandsJson);
                WriteToJson(customCommands, "resources\\custom_commands");
            }

            if (!File.Exists($"{BasePath}\\resources\\inventory_data.json"))
            {
                string inventoryDataJson = Properties.Resources.inventory_data;
                var    inventoryData     = JsonConvert.DeserializeObject <Dictionary <string, Playlist> >(inventoryDataJson);
                WriteToJson(inventoryData, "resources\\inventory_data");
            }

            if (!File.Exists($"{BasePath}\\resources\\playlists.json"))
            {
                string playlistsJson = Properties.Resources.playlists;
                var    playlists     = JsonConvert.DeserializeObject <Dictionary <string, Playlist> >(playlistsJson);
                WriteToJson(playlists, "resources\\playlists");
            }

            if (!File.Exists($"{BasePath}\\resources\\raz_pets.json"))
            {
                string razPetsJson = Properties.Resources.raz_pets;
                var    razPets     = JsonConvert.DeserializeObject <List <string> >(razPetsJson);
                WriteToJson(razPets, "resources\\raz_pets");
            }

            if (!File.Exists($"{BasePath}\\resources\\moderators.json"))
            {
                string moderatorsJson = Properties.Resources.moderators;
                var    moderators     = JsonConvert.DeserializeObject <List <string> >(moderatorsJson);
                WriteToJson(moderators, "resources\\moderators");
            }
        }
Example #4
0
 private static Dictionary <string, Dictionary <string, dynamic> > LoadInventoryData()
 {
     if (File.Exists($"{BotTools.BasePath}\\resources\\inventory_data.json"))
     {
         return(BotTools.ReadFromJson <Dictionary <string, Dictionary <string, dynamic> > >("resources\\inventory_data"));
     }
     else
     {
         return(new Dictionary <string, Dictionary <string, dynamic> >());
     }
 }
Example #5
0
 private Dictionary <string, string> LoadCustomCommands()
 {
     if (File.Exists($"{BotTools.BasePath}\\resources\\custom_commands.json"))
     {
         var functionDict = BotTools.ReadFromJson <Dictionary <string, string> >("resources\\custom_commands");
         return(functionDict);
     }
     else
     {
         return(new Dictionary <string, string>());
     }
 }
Example #6
0
        private static Dictionary <string, Playlist> LoadPlaylists()
        {
            string filePath = $"{BotTools.BasePath}\\resources\\playlists.json";

            if (File.Exists(filePath))
            {
                var pl = BotTools.ReadFromJson <Dictionary <string, Playlist> >("resources\\playlists");
                return(pl);
            }
            else
            {
                var newPL = new Dictionary <string, Playlist>()
                {
                    ["request"] = new Playlist(),
                    ["default"] = new Playlist()
                };
                BotTools.WriteToJson(newPL, "resources\\playlists");
                return(newPL);
            }
        }
Example #7
0
 private string[] GetBuild(TwitchMessage message)
 {
     if (File.Exists($"{BotTools.BasePath}\\resources\\builds.json"))
     {
         string characterName = GuildWars.GetMostRecentCharacter();
         var    builds        = BotTools.ReadFromJson <Dictionary <string, string> >("resources\\builds");
         if (builds.ContainsKey(characterName))
         {
             return(new string[] { $"{characterName}'s build: {builds[characterName]}" });
         }
         else
         {
             return(new string[] { $"No build data for {characterName}" });
         }
     }
     else
     {
         return(new string[] { "I don't know about any builds yet!" });
     }
 }
Example #8
0
        private string[] GetPets(TwitchMessage message)
        {
            var pastPets = BotTools.ReadFromJson <List <string> >("resources\\raz_pets");

            return(new string[] { $"Random Raz pets! -> {pastPets[new Random().Next(pastPets.Count)]}" });
        }