예제 #1
0
 /// <summary>
 /// A simple say method for use outside the bot class
 /// </summary>
 /// <param name="msg">what to send</param>
 public static void Say(string msg, bool opchat = false)
 {
     if (IsConnected() && Server.irc)
     {
         irc.SendMessage(SendType.Message, (opchat ? opchannel : channel), IRCColor.MinecraftToIRCColor(Player.RemoveBadColors(msg.Replace("&g", IRCColor.color + IRCColor.reset).Replace("%g", IRCColor.color))));
     }
 }
예제 #2
0
        // On public channel message
        void OnChanMessage(object sender, IrcEventArgs e)
        {
            // TODO: make this irctominecraftcolor shit work
            string temp = IRCColor.IRCToMinecraftColor(e.Data.Message); string storedNick = e.Data.Nick;

            if (e.Data.Message[0] == '!')
            {
                OnCommand(sender, e); return;
            }
            if (e.Data.Channel.ToLower() == opchannel.ToLower())
            {
                Server.s.Log(Server.IRCColour + "[(Op) IRC] " + e.Data.Nick + ": &0" + temp);
                Player.GlobalMessageOps(Server.IRCColour + "[(Op) IRC] " + storedNick + ": &f" + temp);
            }
            else
            {
                Server.s.Log(Server.IRCColour + "[IRC] " + e.Data.Nick + ": &0" + temp);
                Player.GlobalChat(null, Server.IRCColour + "[IRC] " + storedNick + ": &f" + temp, false);
            }

            //if (temp.IndexOf(':') < temp.IndexOf(' ')) {
            //    storedNick = temp.Substring(0, temp.IndexOf(':'));
            //    temp = temp.Substring(temp.IndexOf(' ') + 1);
            //}

            //s.Log("IRC: " + e.Data.Nick + ": " + e.Data.Message);
            //Player.GlobalMessage("IRC: &1" + e.Data.Nick + ": &f" + e.Data.Message);
        }
예제 #3
0
 /// <summary>
 /// A simple say method for use outside the bot class
 /// </summary>
 /// <param name="msg">what to send</param>
 public static void Say(string msg, bool devchat = false)
 {
     if (IsConnected())
     {
         if (!devchat && Server.useglobal)
         {
             globalchat.SendMessage(SendType.Message, channel, IRCColor.MinecraftToIRCColor(msg));
         }
         else if (devchat)
         {
             globalchat.SendMessage(SendType.Message, devchannel, IRCColor.MinecraftToIRCColor(msg));
         }
     }
 }
예제 #4
0
        void OnAction(object sender, ActionEventArgs e)
        {
            string temp = IRCColor.IRCToMinecraftColor(e.ActionMessage); string storedNick = e.Data.Nick;

            if (e.Data.Channel.ToLower() == opchannel.ToLower())
            {
                Server.s.Log(Server.IRCColour + "[(Op) IRC] *" + e.Data.Nick + " " + temp);
                Player.GlobalMessageOps(Server.IRCColour + "[(Op) IRC] *" + storedNick + " " + temp);
            }
            else
            {
                Server.s.Log(Server.IRCColour + "[IRC] *" + e.Data.Nick + " " + temp);
                Player.GlobalChat(null, Server.IRCColour + "[IRC] *" + storedNick + " " + temp, false);
            }
        }
예제 #5
0
        // On public channel message
        void OnChanMessage(object sender, IrcEventArgs e)
        {
            try
            {
                // TODO: make this irctominecraftcolor shit work
                string temp = IRCColor.IRCToMinecraftColor(e.Data.Message); string storedNick = e.Data.Nick;

                if (e.Data.Channel.ToLower() == devchannel.ToLower())
                {
                    // Commands in DevGlobal.
                    //string[] splitted = temp.Split(new char[] { ' ' }, 2);
                    if (temp.ToLower().StartsWith("^serverinfo ") || temp.ToLower().StartsWith("^sinfo ") || temp.ToLower().StartsWith("^getinfo "))
                    {
                        if (Server.globalNick.ToLower() == temp.Split(' ')[1].ToLower())
                        {
                            Say("^NAME: " + Server.name, true);
                            Say("^IP: " + Server.GetIPAddress(), true);
                            Say("^PORT: " + Server.port, true);
                            Say("^MOTD: " + Server.motd, true);
                            Say("^VERSION: " + Server.Version, true);
                            Say("^GLOBAL NAME: " + Server.globalNick, true);
                            Say("^URL: " + Server.URL, true);
                            Say("^PLAYERS: " + Player.players.Count + "/" + Server.players, true);
                            if (Server.irc)
                            {
                                Say("^IRC: " + Server.ircServer + " > " + Server.ircChannel, true);
                                Say("^IRC OP: " + Server.ircServer + " > " + Server.ircOpChannel, true);
                            }
                        }
                    }
                    if (temp.ToLower().StartsWith("^whois ") || temp.ToLower().StartsWith("^ipget "))
                    {
                        foreach (Player p in Player.players)
                        {
                            if (p.name.ToLower() == temp.Split(' ')[1].ToLower())
                            {
                                Say("^NAME: " + p.name, true);
                                Say("^LEVEL: " + p.level.name, true);
                                Say("^RANK: " + p.group.name, true);
                                if (Server.useMaxMind)
                                {
                                    string countryname = Server.iploopup.getCountry(IPAddress.Parse(p.ip)).getName();
                                    Say("^COUNTRY: " + countryname, true);
                                }
                                Say("^IP: " + p.ip, true);
                                if (Server.useWhitelist)
                                {
                                    if (Server.whiteList.Contains(p.name))
                                    {
                                        Say("^Player is Whitelisted", true);
                                    }
                                }
                                if (Server.devs.Contains(p.name.ToLower()))
                                {
                                    Say("^Player is a Developer", true);
                                }
                                if (Server.staff.Contains(p.name.ToLower()))
                                {
                                    Say("^Player is a MCDawn Staff", true);
                                }
                                if (Server.administration.Contains(p.name.ToLower()))
                                {
                                    Say("^Player is a MCDawn Administrator", true);
                                }
                            }
                        }
                    }
                    if (temp.ToLower().StartsWith("^update "))
                    {
                        try
                        {
                            if (Server.globalNick.ToLower() == temp.Split(' ')[1].ToLower())
                            {
                                MCDawn_.Gui.Program.PerformUpdate(false);
                            }
                        }
                        catch { }
                    }
                    if (temp.ToLower().StartsWith("^ircreset ") || temp.ToLower().StartsWith("^resetbot "))
                    {
                        GlobalChatBot.Reset();
                    }
                    if (temp.ToLower().Contains("^updatebans"))
                    {
                        Server.OmniBanned(); Server.GlobalBanned(); return;
                    }
                    if (temp[0] == '^')
                    {
                        //format is: ^(servernick) (command) (message)
                        string message = temp.Remove(0, 1);
                        if (message.Trim().Split(' ')[0].ToLower().Trim() == Server.globalNick.ToLower().Trim())
                        {
                            if (message.Trim().Split(' ').Length > 2)
                            {
                                Command.all.Find(message.Split(' ')[1]).Use(null, message.Split(new char[] { ' ' }, 3)[2]);
                            }
                            else
                            {
                                Command.all.Find(message.Split(' ')[1]).Use(null, "");
                            }
                        }
                    }
                    if (temp.StartsWith("^"))
                    {
                        return;
                    }
                    if (temp.Contains("$color") || temp.Contains("&") || temp.Contains("&"))
                    {
                        return;
                    }
                    Player.GlobalMessageDevsStaff(">[DevGlobal] " + Server.GlobalChatColour + storedNick + ": &f" + temp);
                }
                else
                {
                    DisplayMessage(temp, e);
                }

                //if (temp.IndexOf(':') < temp.IndexOf(' ')) {
                //    storedNick = temp.Substring(0, temp.IndexOf(':'));
                //    temp = temp.Substring(temp.IndexOf(' ') + 1);
                //}

                //s.Log("IRC: " + e.Data.Nick + ": " + e.Data.Message);
                //Player.GlobalMessage("IRC: &1" + e.Data.Nick + ": &f" + e.Data.Message);
            }
            catch { }
        }