示例#1
0
        public void AddTask(EchoTask task)
        {
            //FloodPreventionInfo.Add(task.Name, Tuple.Create(MiscUtil.GetUnixTime() - time, time));
            //AllowedResponses.Add(task.Name, true);

            Tasks.Add(task.Name, task);
        }
示例#2
0
        public void EncodingTest()
        {
            EchoTask echo = new EchoTask();

            Assert.AreEqual(65001, echo.Encoding.CodePage, "#1");
            Assert.AreEqual(new byte [0], echo.Encoding.GetPreamble(), "#2");
            echo.Encoding = Encoding.ASCII;
            Assert.AreEqual(Encoding.ASCII, echo.Encoding, "#3");
            echo.Encoding = null;
            Assert.AreEqual(65001, echo.Encoding.CodePage, "#4");
            Assert.AreEqual(new byte [0], echo.Encoding.GetPreamble(), "#5");
        }
示例#3
0
        public async Task MainAsyncTask()
        {
            //Load main configuration file
            Configuration.LoadConfig("config.yaml");

            //Initialize logger
            Logger.Info("Connecting!");

            //Initialize Tasking mechanism
            TaskHandler = new Tasking();

#if DEBUG
            EchoTask KelvinEcho = new EchoTask()
            {
                Name     = MainUserKelvin.Username,
                Response = "Shut up Kelvin",
                MinTime  = 30
            };

            EchoTask ShwangEcho = new EchoTask()
            {
                Name     = MainUserShwang.Username,
                Response = "Howdy partner",
                MinTime  = 30
            };

            EchoTask KoyaEcho = new EchoTask()
            {
                Name     = MainUserKoya.Username,
                Response = KELVIN_EMOJI_STRING,
                MinTime  = 1
            };
            TaskHandler.AddTask(KelvinEcho);
            TaskHandler.AddTask(KoyaEcho);
            TaskHandler.AddTask(ShwangEcho);
#endif
            // Handle event listeners
            Client                  = new DiscordSocketClient();
            Client.Log             += Log;
            Client.MessageReceived += Message_Received;
            Client.Connected       += Client_Connected;

            //  You can assign your bot token to a string, and pass that in to connect.
            //  This is, however, insecure, particularly if you plan to have your code hosted in a public repository.
            var token = Configuration.GetConfig("key");

            await Client.LoginAsync(TokenType.Bot, token);

            await Client.StartAsync();

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }