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()); }
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); }
protected void UserJoined(NetChannel channel, NetUser user) { if (channel != null) { channel.HandleJoined(user); } }
protected void UserLeft(NetChannel channel, NetUser user) { if (channel != null) { channel.HandleLeft(user); } }
public bool IsOpInChannel(NetChannel channel) { return IsOpInChannel(channel.Name); }