示例#1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            var    Instance = new Slack();
            string token    = "";
            bool   success;

            Instance.OnEvent += Instance_OnEvent;
            do
            {
                if (File.Exists("token.txt"))
                {
                    token = File.ReadAllText("token.txt");
                }
                if (String.IsNullOrWhiteSpace(token))
                {
                    Console.WriteLine("Please obtain a Token, and paste it below:");
                    token = Console.ReadLine();
                    File.WriteAllText("token.txt", token);
                }
                success = Instance.Init(token);
                if (!success)
                {
                    File.WriteAllText("token.txt", "");
                }
            } while (!success);
            Instance.Connect();
            while (Instance.Connecting || Instance.Connected)
            {
                Thread.Sleep(0);
            }
            Console.WriteLine("===Disconnected===");
            Console.ReadKey();
        }
示例#2
0
        public void TestConnect()
        {
            var slack = new Slack();

            Assert.IsTrue(slack.Init(Token), "Invalid Token");
            Assert.IsTrue(slack.Connect(), "Failed to Connect");
        }
示例#3
0
        public void TestConnect()
        {
            if (String.IsNullOrWhiteSpace(Token))
            {
                Assert.Inconclusive("No valid token specified");
                return;
            }
            var slack = new Slack(Token);

            Assert.IsTrue(slack.Init(), "Invalid Token");
            Assert.IsTrue(slack.Connect(), "Failed to Connect");
        }
示例#4
0
        public void TestSend()
        {
            var slack = new Slack();

            Assert.IsTrue(slack.Init(Token), "Invalid Token");
            Assert.IsTrue(slack.Connect(), "Failed to Connect");
            while (!slack.RecievedHello)
            {
                Thread.Sleep(0);
            }
            slack.SendMessage(slack.GetChannel("#botspam").Id, "Test!");
            slack.SendMessage("#botspam", "Test2");
        }