示例#1
0
        private SlackSocketClient GetClient(string authToken)
        {
            SlackSocketClient client;

            using (var syncClient = new InSync($"{nameof(SlackClient.Connect)} - Connected callback"))
                using (var syncClientSocket = new InSync($"{nameof(SlackClient.Connect)} - SocketConnected callback"))
                {
                    client = new SlackSocketClient(authToken);
                    client.Connect(x =>
                    {
                        Console.WriteLine("Connected");
                        syncClient.Proceed();
                    }, () =>
                    {
                        Console.WriteLine("Socket Connected");
                        syncClientSocket.Proceed();
                    });
                }
            return(client);
        }
示例#2
0
        public void PostTextMessage(string channelName, string msg)
        {
            var client = BotClient;
            PostMessageResponse actual = null;

            using (var sync = new InSync(nameof(SlackClient.PostMessage)))
            {
                client.GetChannelList(clr => { Console.WriteLine("got channels"); });
                var c = client.Channels.Find(x => x.name == channelName);
                client.PostMessage(
                    response =>
                {
                    Console.WriteLine($"sent message to {channelName}!");
                    actual = response;
                    sync.Proceed();
                },
                    c.id,
                    msg);
            }

            Console.WriteLine(!actual.ok ? "Error while posting message to channel. " : $"{actual.ts}:{actual.message.text}");
        }