Example #1
0
 public IrcChannel AddChannel(IrcChannel c)
 {
     if (!Channels.Contains (c)) {
         Channels.Add (c);
     }
     return c;
 }
Example #2
0
 public bool Msg(IrcChannel chan, string msg)
 {
     return Write ("PRIVMSG " + chan.Identifier + " :" + msg);
 }
Example #3
0
        public void Run()
        {
            string raw;
            int cycle = 0;
            isInitialized = !isInitialized; /* Set program is running */
            while ((raw = Reader.ReadLine()) != null) {
                try {
                    if (weAreDebugging) {
                        Console.WriteLine (">> "+raw);
                    }
                    if (cycle == 0) {
                        /* OMG we have connected woo */
                        SendUser(Config.User, Config.Real);
                        SendNick(Config.Nick);
                    }
                    IrcLine line = IrcLine.Parse (raw);
                    if ("PING".Is (line.Method)) {
                        Exec("PONG", line);
                    }

                    if (((int)NumericMethod.EndOfMotd).ToString ().Is (line.Method)) {
                        onNumericMethod("onEndOfMotd", line);
                    }

                    if (((int)NumericMethod.Names).ToString ().Is (line.Method)) {
                        onNumericMethod("onNames", line);
                    }

                    if ("JOIN".Is (line.Method)) {
                        onNumericMethod ("onJoin", line);
                    }

                    if ("PRIVMSG".Is(line.Method)) {
                        var split = line.Data.Split (new char[] {' '}, 2);
                        var chan = new IrcChannel(split[0], new List<string>());
                        var msg = split[1].TrimColon();
                        bool @private = chan.Identifier.ToLower () == Config.Nick.ToLower ();
                        if (@private) {
                            chan = Config.Nick;
                        }
                        Console.WriteLine ("<"+line.Mask.Nick+"> ["+chan+"]: " + msg);
                        if (msg.Substring (0, Config.CmdPrefix.Length) == Config.CmdPrefix) {
                            split = msg.Split (new char[] {' '}, 2);
                            var rest = "";
                            if (split.Length > 1) {
                                rest = split[1];
                            }
                            // Command code.
                            callCommand (split[0], line, chan, rest);
                        }
                    }
                }
                catch (Exception e) {
                    Console.WriteLine ("Hahahahaha I am such a lollygagger. (Something went wrong)");
                    Console.WriteLine (e.ToString());
                }
                cycle++;
            }
        }
Example #4
0
 public void RemoveChannel(IrcChannel c)
 {
     Channels.RemoveAll (channel => channel == c);
 }