Esempio n. 1
0
        void DoJoinLeaveMessage(string who, string verb, string channel)
        {
            Server.s.Log(String.Format("{0} has {1} channel {2}", who, verb, channel));
            string which = channel.CaselessEq(opchannel) ? " operator" : "";

            Player.GlobalIRCMessage(String.Format("%I[IRC] {0} has {1} the{2} channel", who, verb, which));
        }
Esempio n. 2
0
        void Listener_OnKick(UserInfo user, string channel, string kickee, string reason)
        {
            List <string> chanNicks = GetNicks(channel);

            RemoveNick(user.Nick, chanNicks);
            Server.s.Log(kickee + " kicked " + user.Nick + " from IRC");
            Player.GlobalIRCMessage("%I[IRC] " + kickee + " kicked " + user.Nick);
        }
Esempio n. 3
0
        void Listener_OnNick(UserInfo user, string newNick)
        {
            //Player.GlobalMessage(Server.IRCColour + "[IRC] " + user.Nick + " changed nick to " + newNick);
            // We have successfully reclaimed our nick, so try to sign in again.
            if (newNick == nick)
            {
                Authenticate();
            }

            if (newNick.Trim() == "")
            {
                return;
            }

            foreach (var kvp in users)
            {
                int index = GetNickIndex(user.Nick, kvp.Value);
                if (index >= 0)
                {
                    string prefix = GetPrefix(kvp.Value[index]);
                    kvp.Value[index] = prefix + newNick;
                }
                else
                {
                    // should never happen, but just in case.
                    connection.Sender.Names(kvp.Key);
                }
            }

            string key;

            if (newNick.Split('|').Length == 2)
            {
                key = newNick.Split('|')[1];
                if (key != null && key != "")
                {
                    switch (key)
                    {
                    case "AFK":
                        Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " %Sis AFK"); Server.ircafkset.Add(user.Nick); break;

                    case "Away":
                        Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " %Sis Away"); Server.ircafkset.Add(user.Nick); break;
                    }
                }
            }
            else if (Server.ircafkset.Contains(newNick))
            {
                Player.GlobalIRCMessage("%I[IRC] " + newNick + " %Sis back");
                Server.ircafkset.Remove(newNick);
            }
            else
            {
                Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " %Sis now known as %I" + newNick);
            }
        }
Esempio n. 4
0
        void Listener_OnQuit(UserInfo user, string reason)
        {
            List <string> chanNicks = GetNicks(channel);

            RemoveNick(user.Nick, chanNicks);
            if (user.Nick == nick)
            {
                return;
            }
            Server.s.Log(user.Nick + " has left IRC");
            Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " has left");
        }
Esempio n. 5
0
        void Listener_OnQuit(UserInfo user, string reason)
        {
            // Old bot was disconnected, try to reclaim it.
            if (user.Nick == nick)
            {
                connection.Sender.Nick(nick);
            }

            RemoveNick(user.Nick);
            if (user.Nick == nick)
            {
                return;
            }
            Server.s.Log(user.Nick + " left IRC");
            Player.GlobalIRCMessage("%I[IRC] " + user.Nick + " left");
        }
Esempio n. 6
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            message = message.TrimEnd();
            if (message.Length == 0)
            {
                return;
            }
            bool opchat = channel.CaselessEq(opchannel);

            message = Colors.IrcToMinecraftColors(message);
            message = CP437Reader.ConvertToRaw(message);
            string[] parts  = message.SplitSpaces(3);
            string   ircCmd = parts[0].ToLower();

            string nick = opchat ? "#@private@#" : "#@public@#";

            if (HandleWhoCommand(nick, ircCmd, opchat))
            {
                return;
            }

            if (ircCmd == ".x" && !HandlePublicCommand(user, channel, message, parts, opchat))
            {
                return;
            }

            if (channel.CaselessEq(opchannel))
            {
                Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
                Chat.MessageOps(String.Format("To Ops &f-%I[IRC] {0}&f- {1}", user.Nick,
                                              Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
            else
            {
                Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
                Player.GlobalIRCMessage(String.Format("%I[IRC] {0}: &f{1}", user.Nick,
                                                      Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
        }
Esempio n. 7
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            message = Colors.IrcToMinecraftColors(message);
            message = CP437Reader.ConvertToRaw(message);
            string[] parts  = message.Split(trimChars, 3);
            string   ircCmd = parts[0].ToLower();

            if (ircCmd == ".who" || ircCmd == ".players")
            {
                try {
                    CmdPlayers.DisplayPlayers(null, "", text => Say(text, false, true), false, false);
                } catch (Exception e) {
                    Server.ErrorLog(e);
                }
            }

            if (ircCmd == ".x")
            {
                string cmdName = parts.Length > 1 ? parts[1].ToLower() : "";
                string error;
                if (!CheckUserAndCommand(user, cmdName, message, out error))
                {
                    if (error != null)
                    {
                        Server.IRC.Say(error);
                    }
                    return;
                }

                Command cmd = Command.all.Find(cmdName);
                if (cmdName != "" && cmd != null)
                {
                    Server.s.Log("IRC Command: /" + message.Replace(".x ", "") + " (by " + user.Nick + ")");
                    usedCmd = "";
                    string args = parts.Length > 2 ? parts[2] : "";
                    try {
                        cmd.Use(new Player("IRC"), args);
                    } catch (Exception e) {
                        Server.IRC.Say("CMD Error: " + e.ToString());
                    }
                    usedCmd = "";
                }
                else
                {
                    Server.IRC.Say("Unknown command!");
                }
            }

            if (String.IsNullOrEmpty(message.Trim()))
            {
                message = ".";
            }

            if (channel.CaselessEq(opchannel))
            {
                Server.s.Log(String.Format("(OPs): [IRC] {0}: {1}", user.Nick, message));
                Chat.GlobalMessageOps(String.Format("To Ops &f-%I[IRC] {0}&f- {1}", user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
            else
            {
                Server.s.Log(String.Format("[IRC] {0}: {1}", user.Nick, message));
                Player.GlobalIRCMessage(String.Format("%I[IRC] {0}: &f{1}", user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message));
            }
        }
Esempio n. 8
0
 void Listener_OnAction(UserInfo user, string channel, string description)
 {
     Player.GlobalIRCMessage(String.Format("%I[IRC] * {0} {1}", user.Nick, description));
 }