Example #1
0
 /// <summary>
 /// Reads an <see cref="IRCSharp.IrcMessage"/> from the stream.
 /// </summary>
 /// <returns></returns>
 public IrcMessage ReadMessage()
 {
     IrcMessage message = new IrcMessage();
     string line = _reader.ReadLine();
     message.Parse(line);
     return message;
 }
Example #2
0
 /// <summary>
 /// Writes an <see cref="IRCSharp.IrcMessage"/> to the stream.
 /// </summary>
 public void Write(IrcMessage message)
 {
     _writer.WriteLine(message);
 }
Example #3
0
 /// <summary>
 /// Writes an <see cref="IRCSharp.IrcMessage"/> to the stream.
 /// </summary>
 public void Write(IrcMessage message)
 {
     _writer.WriteLine(message);
 }
        public override string ToString()
        {
            IrcMessage message = new IrcMessage();
            List<string> strings = new List<string>();
            if (!string.IsNullOrEmpty(To))
            {
                strings.Add(To);
            }
            if (!string.IsNullOrEmpty(Extra))
            {
                strings.AddRange(Extra.Split(' '));
            }
            if (!string.IsNullOrEmpty(Message))
            {
                strings.Add(Message);
            }

            message.Prefix = Host;
            message.Command = ((int)NumericId).ToString("D3");
            message.Params = strings.ToArray();

            return message.ToString();
        }
 /// <summary>
 /// Parses a responce.
 /// </summary>
 /// <param name="line"></param>
 public void Parse(string line)
 {
     IrcMessage message = new IrcMessage();
     message.Parse(line);
     Host = message.Prefix.Trim();
     NumericId = (IrcNumericResponceId)(int.Parse(message.Command));
     Extra = string.Join(" ", message.Params, 0, message.Params.Length - 1).Trim();
     Message = " :" + message.Params.Last().Trim();
 }
Example #6
0
 private void ProcessCommand(IrcMessage message)
 {
     if(!message.Sender.Ident.Equals("~baggerboo"))
     {
         client.SendMessage(message.Channel, "You are not authorized to use commands.");
     }
     string command = message.Message.Substring(1);
     string[] args = command.Substring(command.IndexOf(' ')+1).Split(' ');
     if (command.StartsWith("join")) {
         client.JoinChannel(args[0]);
     } else if (command.StartsWith("part")) {
         client.LeaveChannel(message.Channel);
     } else if (command.StartsWith("nick")) {
         client.ChangeNick(args[0]);
     }
     Console.WriteLine("Invalid Command");
 }