Make your own custom Minecraft bot (not IRC)

Make your own custom Minecraft bot (not IRC)

Postby Leeizazombie » 30 Nov 2013, 17:47

Hey guys, glad to come back and start making commands again, my first one is a command I tought about and I've tested it a few times and well have a look:
I used the player.joined event and the chatfilter features that Dzienny has brought into the source! :D
Code: Select all
using System.Threading;
using System;

namespace MCDzienny


#region Settings
{
    public class CmdWelcome_bot : Command
    {
        public override string name { get { return "lbs"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "mod"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
        public override void Use(Player p, string message)
        {
            Player.GlobalMessage(" %f[%bLeeBot%f]: " + message);
           
        }
#endregion


#region Joined server
        public override void Init()
        {
           
            Player.Joined += (object sender, PlayerEventArgs e) =>
            {

                Player.GlobalMessage("%f[%bLeeBot%f]: Hey %a$name! %fWelcome to $server.:D");

            };

            Player.PlayerChatEvent += FilterChat;
        }
#endregion


#region greetings
        private void FilterChat(Player p, ref string message, ref bool stopIt)
        {
           
            string botCmd = message;
            if (botCmd.Contains("hey leebot"))
            {
                Player.GlobalMessage(p.color + p.name + "%f to %f[%bLeeBot%f]: " + message);
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.name + "%f!");
            }

            else if
                (botCmd.Contains("hi leebot"))
            {
                Player.GlobalMessage(p.color + p.name + "%f to %f[%bLeeBot%f]: " + message);
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.name + "%f!");
            }
            else if (botCmd.Contains("Hey leebot"))
            {
                Player.GlobalMessage(p.color + p.name + "%f to %f[%bLeeBot%f]: " + message);
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Hello there, " + p.color + p.name + "%f!");
            }
#endregion


#region I'm back
            if (botCmd.Contains("I'm back"))
            {
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Welcome back, " + p.color + p.name + "%f!");
            }

            else if (botCmd.Contains("i'm back"))
            {
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Welcome back, " + p.color + p.name + "%f!");
            }
            else if (botCmd.Contains("im back"))
            {
                Player.GlobalMessage(" %bLeeBot%f is typing... ");
                Thread.Sleep(2000);
                message = null;
                Player.GlobalMessage("%f[%bLeeBot%f]: Welcome back, " + p.color + p.name + "%f!");
            }
        }
#endregion

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/lbs to speak as the bot");
        }
    }
}


It basically makes the bot respond to a normal text from a Minecraft player, mess around with the code and see how you do! ;) use /lbs (message) to speak as the bot.
ps: If anyone can suggest how to remove the case sensitivity that would be great!
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: Make your own custom Minecraft bot (not IRC)

Postby joppiesaus » 30 Nov 2013, 18:12

Awsome!
You can use in the region I'm back this code for less code!
Code: Select all
if (botCmd.ToLower().Contains("back") && botCmd.ToLower().Contains("i"))
{
   // Code here. You never say I peter is back. or something.
}
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: Make your own custom Minecraft bot (not IRC)

Postby Leeizazombie » 30 Nov 2013, 18:31

Cool, thanks!
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 6 guests

cron