示例#1
0
        public Bot(string configFile, NetMaster master)
        {
            config = XDocument.Load(configFile);

            var server = (from s in config.Descendants("Server")
                          select new { host = s.Element("Host").Value, port = s.Element("Port").Value, name = s.Element("Nickname").Value, channel = s.Element("Channel").Value, password = s.Element("Password") }
                         ).ElementAt(0);

            if(master == null) {
                Log.Info("Connecting to " + server.host + ":" + server.port);
                this.net = new IrcMaster(server.host, Int32.Parse(server.port));
            }
            else {
                this.net = master;
            }

            games = new GameManager(this);

            string password = null;
            if(server.password != null) {
                password = server.password.Value;
            }
            Log.Info("Logging in as " + server.name + " (Using Password: "******")");
            if (net is IrcMaster) {
                (net as IrcMaster).Login(server.name, "MafiaBot V2", password);
            }

            mainChannel = net.GetChannel(server.channel);

            mainChannel.Commands.Add(new Commands.VariantsCommand());
            mainChannel.Commands.Add(new Commands.CreateCommand(this));
            mainChannel.Commands.Add(new Commands.ListCommand(this));
            mainChannel.Commands.Add(new Commands.OpDestroyCommand(this));
            mainChannel.Commands.Add(new Commands.HelpCommand());
        }
示例#2
0
        public BasicGame(Bot bot, NetUser creator, string name, string channelPrefix)
        {
            this.name = name;
            this.creator = creator;

            this.bot = bot;
            this.channel = Bot.Master.GetChannel("#" + channelPrefix + name);

            this.channel.Joined += new EventHandler<UserEventArgs>(OnJoin);
            this.channel.Left += new EventHandler<UserEventArgs>(OnLeft);
        }
示例#3
0
 protected void UserJoined(NetChannel channel, NetUser user)
 {
     if (channel != null) {
         channel.HandleJoined(user);
     }
 }
示例#4
0
 protected void UserLeft(NetChannel channel, NetUser user)
 {
     if (channel != null) {
         channel.HandleLeft(user);
     }
 }
示例#5
0
 public bool IsOpInChannel(NetChannel channel)
 {
     return IsOpInChannel(channel.Name);
 }