Esempio n. 1
0
        public bool HandleEvent(string payload)
        {
            var jsonObj = JObject.Parse(payload);

            ConsoleMessenger.PrintError("Could not parse Unknown Type: " + jsonObj["type"].ToString());
            return(true);
        }
        //THIS IS A RECURSIVE FUNCTION
        public static WebSocketSharp.WebSocket GetSocket()
        {
            if (CurrentAttempt <= ConnectionAttempts)
            {
                if (ConnectedSocket != null)
                {
                    CurrentAttempt = 0;
                    return(ConnectedSocket);
                }
                else
                {
                    CurrentAttempt++;
                    ConsoleMessenger.PrintError("Trying to reconnect");
                    Connect();
                    return(GetSocket());
                }
            }
            ConsoleMessenger.PrintError("Connection To Slack Failed\nPress ENTER to exit or type \"retry\" to try again");
            var input = Console.ReadLine();

            if (input == "retry")
            {
                CurrentAttempt = 0;
                GetSocket();
            }
            Environment.Exit(0);
            return(null);
        }
Esempio n. 3
0
 /// <summary>
 /// Returns a user if found, else it returns null
 /// </summary>
 /// <param name="NameOrId"></param>
 /// <returns>a User</returns>
 public static User FindUser(string NameOrId)
 {
     foreach (var u in GetUsers())
     {
         if (u.name.Equals(NameOrId) || u.id.Equals(NameOrId))
         {
             return(u);
         }
     }
     ConsoleMessenger.PrintError($"{NameOrId} not found");
     return(null);
 }
Esempio n. 4
0
        public static void Load()
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings.Clear();
            try {
                var lines = File.ReadLines(".env");
                foreach (var line in lines)
                {
                    var data = line.Split('=');
                    config.AppSettings.Settings.Add(data[0], data[1]);
                    config.Save(ConfigurationSaveMode.Modified, true);
                    ConfigurationManager.RefreshSection("appSettings");
                }
            }
            catch (FileNotFoundException) {
                ConsoleMessenger.PrintError("Could not locate .env file");
            }
            catch (PathTooLongException) {
                ConsoleMessenger.PrintError("File path too long");
            }
            ConsoleMessenger.PrintSuccess(".env loaded");
        }