예제 #1
0
        /// <summary>
        /// sends a message to the channel
        /// </summary>
        /// <param name="message">message to send</param>
        public void SendMessage(string message)
        {
            Logger.Info(this, "Sending message to channel", message);
            string[] messages = message.SplitMessage(500).ToArray();

            foreach (string chunk in messages)
            {
                channel.SendMessage(chunk);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Logger.EnableConsoleLogging();
            ChatClient chatclient = new ChatClient();

            chatclient.Disconnected  += OnDisconnected;
            chatclient.ChannelJoined += OnChannelJoined;
            chatclient.ChannelLeft   += OnChannelLeft;

            try
            {
                chatclient.Connect(args[0], args[1]);
            }
            catch (Exception e) {
                Logger.Error(typeof(Program), "Unable to connect to twitch", e);
            }

            Logger.Info("Program", "Connected");
            chatclient.Join(args[0]);

            string line = "";

            do
            {
                line = Console.ReadLine();
                if (line.ToLower() != "quit")
                {
                    int index = line.IndexOf(' ');
                    if (index > -1)
                    {
                        ChatChannel channel = chatclient.GetChannel(line.Substring(0, index));
                        if (channel != null)
                        {
                            channel.SendMessage(line.Substring(index + 1));
                        }
                        else
                        {
                            Logger.Error("Program", $"Channel '{line.Substring(0, index)}' not found");
                        }
                    }
                    else
                    {
                        Logger.Error("Program", "Invalid syntax");
                    }
                }
            }while(line.ToLower() != "quit");
        }