bobbot-cvs Mailing List for BoB (Page 2)
Status: Alpha
Brought to you by:
iainmckay
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(17) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(66) |
Feb
(31) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(18) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
From: Iain M. <iai...@us...> - 2005-02-28 01:53:31
|
Update of /cvsroot/bobbot/Plugins/Quakenet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12964/Quakenet Log Message: Directory /cvsroot/bobbot/Plugins/Quakenet added to the repository |
From: Iain M. <iai...@us...> - 2005-02-28 01:21:31
|
Update of /cvsroot/bobbot/Bob/Core/Irc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4771/Core/Irc Modified Files: NetworkConnection.cs Log Message: Fixed: - Bug in NetworkConnection.Send(). Would cause an ArgumentNullException when trying to send a message but aren't connected to a server. Index: NetworkConnection.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/Irc/NetworkConnection.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NetworkConnection.cs 28 Feb 2005 00:10:41 -0000 1.10 --- NetworkConnection.cs 28 Feb 2005 01:21:20 -0000 1.11 *************** *** 379,382 **** --- 379,386 ---- throw new ObjectDisposedException("NetworkConnection"); + if(!m_Connected) { + return; + } + m_NetworkPump.Enqueue(new RawMessage(rawMessage)); } *************** *** 388,398 **** public void Send(BaseMessage msg) { ! if(Disposed) throw new ObjectDisposedException("NetworkConnection"); // Ignore any messages until we have connected. Allow registration // and pings to get through regardless. ! if(!m_Registered && (!(msg is NickMessage) && !(msg is UserMessage) && !(msg is PongMessage))) return; m_NetworkPump.Enqueue(msg); --- 392,404 ---- public void Send(BaseMessage msg) { ! if(Disposed) { throw new ObjectDisposedException("NetworkConnection"); + } // Ignore any messages until we have connected. Allow registration // and pings to get through regardless. ! if(!m_Connected || (!m_Registered && (!(msg is NickMessage) && !(msg is UserMessage) && !(msg is PongMessage)))) { return; + } m_NetworkPump.Enqueue(msg); *************** *** 826,829 **** --- 832,836 ---- m_Connected = false; + m_Registered = false; if(Disconnected != null) { |
From: Iain M. <iai...@us...> - 2005-02-28 00:10:50
|
Update of /cvsroot/bobbot/Bob/Core/Irc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16515/Core/Irc Modified Files: NetworkConnection.cs NetworkUser.cs Log Message: Changed: - NetworkUser.Parse() made public. - NetworkConnection.Send(string rawMessage) now implemented. - Bot will try to rejoin a channel if it has been kicked. - When a user parts all known channels they are given 20 seconds to rejoin or a quit is raised for them. Fixed: - Bug in NetworkUser.Parse() where it would not correctly parse n!u@h without a leading colon. - Bug when NetworkConnection.NickChanged was raised the args From property would already reflect the new nick. NetworkUser now subscribes to a new internal event that is raised after NetworkConnection.NickChanged. - Bug with wildcards in user hosts, processed correctly now. Added: - NetworkConnection.SendRawMessage(). Use to send a raw irc message. - NetworkConnection.SendKick(). Use to kick a user. - NetworkConnection.Kick event. Raised when a user is kicked from a channel. - NetworkUser.SendKick(). Use to kick this user from a channel. - NetworkUser.Kick event. Raised when the user is kicked from a channel. - User.ClearHosts(). Added to complete the User.*Host method set. Index: NetworkConnection.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/Irc/NetworkConnection.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NetworkConnection.cs 16 Jan 2005 03:16:21 -0000 1.9 --- NetworkConnection.cs 28 Feb 2005 00:10:41 -0000 1.10 *************** *** 242,247 **** --- 242,251 ---- /// <summary>Raised when a channel part occurs.</summary> public event PartMessageEventHandler Part; + /// <summary>Raised when a user joins a channel.</summary> + public event JoinMessageEventHandler Join; /// <summary>Raised when we receive a ping.</summary> public event PingMessageEventHandler Ping; + /// <summary>Raised when a user is kicked from a channel.</summary> + public event KickMessageEventHandler Kick; /// <summary>Raised when a user quits IRC.</summary> public event QuitMessageEventHandler Quit; *************** *** 252,257 **** /// <summary>Raised when a mode change occurs.</summary> public event ModeMessageEventHandler ModeChanged; ! /// <summary>Raised when a user joins a channel.</summary> ! public event JoinMessageEventHandler Join; /// <summary>Raised when we receive a channel message.</summary> public event ChannelMessageEventHandler ChannelMessage; --- 256,260 ---- /// <summary>Raised when a mode change occurs.</summary> public event ModeMessageEventHandler ModeChanged; ! /// <summary>Raised when we receive a channel message.</summary> public event ChannelMessageEventHandler ChannelMessage; *************** *** 261,264 **** --- 264,270 ---- /// <summary>Raised when we receive a raw message.</summary> public event MessageReceivedEventHandler MessageReceived; + + // NetworkUser subscribes to this event to make sure they are updated last. + internal event NickMessageEventHandler NickChangedInternal; #endregion *************** *** 274,277 **** --- 280,284 ---- MessageFactory.Instance.Register(typeof(JoinMessage)); MessageFactory.Instance.Register(typeof(PartMessage)); + MessageFactory.Instance.Register(typeof(KickMessage)); MessageFactory.Instance.Register(typeof(PingMessage)); MessageFactory.Instance.Register(typeof(NickMessage)); *************** *** 372,376 **** throw new ObjectDisposedException("NetworkConnection"); ! throw new Exception("Not implemented yet."); } --- 379,383 ---- throw new ObjectDisposedException("NetworkConnection"); ! m_NetworkPump.Enqueue(new RawMessage(rawMessage)); } *************** *** 614,617 **** --- 621,686 ---- Send(new JoinMessage(dest, key)); } + + public void SendRawMessage(string message, params object[] args) + { + if(message == null) + throw new ArgumentNullException("message", "message cannot be null"); + + Send(new RawMessage(String.Format(message, args))); + } + + public void SendKick(string dest, string victim) + { + if(dest == null) { + throw new ArgumentNullException("dest", "dest cannot be null"); + } + if(victim == null) { + throw new ArgumentNullException("victim", "victim cannot be null"); + } + + Send(new KickMessage(dest, victim)); + } + + public void SendKick(NetworkChannel dest, NetworkUser victim) + { + if(dest == null) { + throw new ArgumentNullException("dest", "dest cannot be null"); + } + if(victim == null) { + throw new ArgumentNullException("victim", "victim cannot be null"); + } + + Send(new KickMessage(dest, victim)); + } + + public void SendKick(string dest, string victim, string reason, params object[] args) + { + if(dest == null) { + throw new ArgumentNullException("dest", "dest cannot be null"); + } + if(victim == null) { + throw new ArgumentNullException("victim", "victim cannot be null"); + } + if(reason == null) { + throw new ArgumentNullException("reason", "reason cannot be null"); + } + + Send(new KickMessage(dest, victim, String.Format(reason, args))); + } + + public void SendKick(NetworkChannel dest, NetworkUser victim, string reason, params object[] args) + { + if(dest == null) { + throw new ArgumentNullException("dest", "dest cannot be null"); + } + if(victim == null) { + throw new ArgumentNullException("victim", "victim cannot be null"); + } + if(reason == null) { + throw new ArgumentNullException("reason", "reason cannot be null"); + } + + Send(new KickMessage(dest, victim, String.Format(reason, args))); + } #endregion *************** *** 692,707 **** private void OnConnectedSync(IAsyncResult ar) { ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) m_SyncRoot.BeginInvoke(m_OnConnected, new object[] { this, new ConnectedEventArgs() }); ! else OnConnected(this, new ConnectedEventArgs()); } private void OnDisconnectedSync(object sender, DisconnectedEventArgs args) { ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) m_SyncRoot.BeginInvoke(m_OnDisconnected, new object[] { this, args }); ! else ! OnDisconnected(this, args ); } --- 761,778 ---- private void OnConnectedSync(IAsyncResult ar) { ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) { m_SyncRoot.BeginInvoke(m_OnConnected, new object[] { this, new ConnectedEventArgs() }); ! } else { OnConnected(this, new ConnectedEventArgs()); + } } private void OnDisconnectedSync(object sender, DisconnectedEventArgs args) { ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) { m_SyncRoot.BeginInvoke(m_OnDisconnected, new object[] { this, args }); ! } else { ! OnDisconnected(this, args); ! } } *************** *** 709,716 **** { Console.WriteLine(args.Message); ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) m_SyncRoot.BeginInvoke(m_OnMessageReceived, new object[] {this, args}); ! else OnMessageReceived(this, args); } --- 780,788 ---- { Console.WriteLine(args.Message); ! if((m_SyncRoot != null) && (m_SyncRoot.InvokeRequired)) { m_SyncRoot.BeginInvoke(m_OnMessageReceived, new object[] {this, args}); ! } else { OnMessageReceived(this, args); + } } *************** *** 755,760 **** m_Connected = false; ! if(Disconnected != null) Disconnected(this, args); } --- 827,833 ---- m_Connected = false; ! if(Disconnected != null) { Disconnected(this, args); + } } *************** *** 810,819 **** if(IsMe(args.Message.From)) { ! Log.WriteLine("Irc", "Nick changed to '{0}'", args.Message.NewNick); m_Nickname = args.Message.NewNick; } ! if(NickChanged != null) NickChanged(this, args); } --- 883,897 ---- if(IsMe(args.Message.From)) { ! Log.WriteLine("Irc", "Nick changed to '{0}'", args.Message.From); m_Nickname = args.Message.NewNick; } ! if(NickChanged != null) { NickChanged(this, args); + } + + if(NickChangedInternal != null) { + NickChangedInternal(this, args); + } } *************** *** 910,913 **** --- 988,1012 ---- } + internal void OnKick(KickMessageEventArgs args) + { + if(IsMe(args.Message.Victim)) + { + NetworkChannel channel = args.Message.Channel; + + Log.WriteLine("Irc", "I got kicked from {0}", channel); + + channel.Users.Clear(); + m_Channels.Remove(channel); + } + + if(Kick != null) { + Kick(this, args); + } + + if(IsMe(args.Message.Victim)) { + SendJoin(args.Message.Channel); + } + } + internal void OnQuit(QuitMessageEventArgs args) { Index: NetworkUser.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/Irc/NetworkUser.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NetworkUser.cs 16 Jan 2005 03:16:21 -0000 1.3 --- NetworkUser.cs 28 Feb 2005 00:10:41 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- using System; + using System.Timers; using System.Text.RegularExpressions; *************** *** 80,84 **** private string m_Realname; private string m_Hostname; ! private ChannelCollection m_Channels; #endregion --- 81,86 ---- private string m_Realname; private string m_Hostname; ! ! private Timer m_TimeoutTimer; private ChannelCollection m_Channels; #endregion *************** *** 91,94 **** --- 93,98 ---- /// <summary>Raised when this user quits IRC.</summary> public event QuitMessageEventHandler Quit; + /// <summary>Raised when this user is kicked from a channel.</summary> + public event KickMessageEventHandler Kick; /// <summary>Raised when this user changes their nick.</summary> public event NickMessageEventHandler NickChanged; *************** *** 112,119 **** m_Channels = new ChannelCollection(); Kernel.Instance.Network.Join += new JoinMessageEventHandler(OnJoinChannel); Kernel.Instance.Network.Part += new PartMessageEventHandler(OnPartChannel); Kernel.Instance.Network.Quit += new QuitMessageEventHandler(OnQuit); - Kernel.Instance.Network.NickChanged += new NickMessageEventHandler(OnNickChanged); } #endregion --- 116,124 ---- m_Channels = new ChannelCollection(); + Kernel.Instance.Network.NickChangedInternal += new NickMessageEventHandler(OnNickChanged); Kernel.Instance.Network.Join += new JoinMessageEventHandler(OnJoinChannel); Kernel.Instance.Network.Part += new PartMessageEventHandler(OnPartChannel); + Kernel.Instance.Network.Kick += new KickMessageEventHandler(OnKicked); Kernel.Instance.Network.Quit += new QuitMessageEventHandler(OnQuit); } #endregion *************** *** 123,131 **** /// Sends this user a private message. /// </summary> ! /// <param name="format">Message format.</param> /// <param name="args">Message arguments.</param> ! public void SendMessage(string format, params object[] args) { ! Kernel.Instance.Network.SendPrivateMessage(this.Nickname, format, args); } --- 128,140 ---- /// Sends this user a private message. /// </summary> ! /// <param name="format">Message to send.</param> /// <param name="args">Message arguments.</param> ! public void SendMessage(string message, params object[] args) { ! if(message == null) { ! throw new ArgumentNullException("message", "message cannot be null"); ! } ! ! Kernel.Instance.Network.SendPrivateMessage(this.Nickname, message, args); } *************** *** 133,141 **** /// Sends this user a notice. /// </summary> ! /// <param name="format">Notice format.</param> /// <param name="args">Notice args.</param> ! public void SendNotice(string format, params object[] args) { ! Kernel.Instance.Network.SendNotice(this.Nickname, format, args); } --- 142,196 ---- /// Sends this user a notice. /// </summary> ! /// <param name="message">Message to send.</param> /// <param name="args">Notice args.</param> ! public void SendNotice(string message, params object[] args) { ! if(message == null) { ! throw new ArgumentNullException("message", "message cannot be null"); ! } ! ! Kernel.Instance.Network.SendNotice(this.Nickname, message, args); ! } ! ! public void SendKick(string dest) ! { ! if(dest == null) { ! throw new ArgumentNullException("dest", "dest cannot be null"); ! } ! ! SendKick(dest, ""); ! } ! ! public void SendKick(NetworkChannel dest) ! { ! if(dest == null) { ! throw new ArgumentNullException("dest", "dest cannot be null"); ! } ! ! SendKick(dest, ""); ! } ! ! public void SendKick(string dest, string reason, params object[] args) ! { ! if(dest == null) { ! throw new ArgumentNullException("dest", "dest cannot be null"); ! } ! if(reason == null) { ! throw new ArgumentNullException("reason", "reason cannot be null"); ! } ! ! Kernel.Instance.Network.SendKick(dest, this.Nickname, reason, args); ! } ! ! public void SendKick(NetworkChannel dest, string reason, params object[] args) ! { ! if(dest == null) { ! throw new ArgumentNullException("dest", "dest cannot be null"); ! } ! if(reason == null) { ! throw new ArgumentNullException("reason", "reason cannot be null"); ! } ! ! Kernel.Instance.Network.SendKick(dest, this, reason, args); } *************** *** 159,211 **** #endregion #region Event handlers private void OnJoinChannel(NetworkConnection sender, JoinMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) return; m_Channels.Add(args.Message.Channel); ! if(Join != null) Join(sender, args); } private void OnPartChannel(NetworkConnection sender, PartMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) return; m_Channels.Remove(args.Message.Channel); ! if(Part != null) Part(sender, args); } private void OnNickChanged(NetworkConnection sender, NickMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) return; ! m_Nickname = args.Message.NewNick; ! ! if(NickChanged != null) NickChanged(sender, args); } private void OnQuit(NetworkConnection sender, QuitMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) return; m_Channels.Clear(); ! if(Quit != null) Quit(sender, args); } #endregion #region Static methods ! internal static NetworkUser Parse(string rawUser) { Regex reg = new Regex(":(.+)!(.+)@(.+)|(.+)!(.+)@(.+)", RegexOptions.Compiled); Match match = reg.Match(rawUser); --- 214,331 ---- #endregion + #region Private methods + private void StartTimer() + { + if(m_TimeoutTimer != null) { + StopTimer(); + } + + m_TimeoutTimer = new Timer(20000); + m_TimeoutTimer.AutoReset = false; + m_TimeoutTimer.Elapsed += new ElapsedEventHandler(OnTimeout); + + m_TimeoutTimer.Start(); + } + + private void StopTimer() + { + if(m_TimeoutTimer == null) { + return; + } + + m_TimeoutTimer.Stop(); + m_TimeoutTimer = null; + } + #endregion + #region Event handlers private void OnJoinChannel(NetworkConnection sender, JoinMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) { return; + } m_Channels.Add(args.Message.Channel); ! if(m_TimeoutTimer != null) { ! StopTimer(); ! } ! ! if(Join != null) { Join(sender, args); + } } private void OnPartChannel(NetworkConnection sender, PartMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) { return; + } m_Channels.Remove(args.Message.Channel); ! if(m_Channels.Count == 0) { ! StartTimer(); ! } ! ! if(Part != null) { Part(sender, args); + } } private void OnNickChanged(NetworkConnection sender, NickMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) { return; + } ! if(NickChanged != null) { NickChanged(sender, args); + } + + m_Nickname = args.Message.NewNick; } private void OnQuit(NetworkConnection sender, QuitMessageEventArgs args) { ! if(args.Message.From.Nickname != this.Nickname) { return; + } m_Channels.Clear(); ! if(Quit != null) { Quit(sender, args); + } + } + + private void OnKicked(NetworkConnection sender, KickMessageEventArgs args) + { + if(args.Message.From.Nickname != this.Nickname) { + return; + } + + m_Channels.Remove(args.Message.Channel); + + if(Kick != null) { + Kick(sender, args); + } + } + + private void OnTimeout(object sender, ElapsedEventArgs args) + { + StopTimer(); + + // bit of a hack? + QuitMessage msg = new QuitMessage(); + msg.Parse(String.Format(":{0} QUIT :")); + msg.Notify(Kernel.Instance.Network); } #endregion #region Static methods ! public static NetworkUser Parse(string rawUser) { + // talk about rigid checking.....woooo any more strict and we'd be in a dictatorship! Regex reg = new Regex(":(.+)!(.+)@(.+)|(.+)!(.+)@(.+)", RegexOptions.Compiled); Match match = reg.Match(rawUser); *************** *** 217,220 **** --- 337,347 ---- string host = match.Groups[3].Value; + if(match.Groups[4].Value != String.Empty) + { + nick = match.Groups[4].Value; + user = match.Groups[5].Value; + host = match.Groups[6].Value; + } + if(!IrcHelper.IsValidNickname(nick) || !IrcHelper.IsValidNickname(user)) return null; |
From: Iain M. <iai...@us...> - 2005-02-28 00:10:50
|
Update of /cvsroot/bobbot/Bob/Core/Irc/Collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16515/Core/Irc/Collections Modified Files: ChannelCollection.cs Log Message: Changed: - NetworkUser.Parse() made public. - NetworkConnection.Send(string rawMessage) now implemented. - Bot will try to rejoin a channel if it has been kicked. - When a user parts all known channels they are given 20 seconds to rejoin or a quit is raised for them. Fixed: - Bug in NetworkUser.Parse() where it would not correctly parse n!u@h without a leading colon. - Bug when NetworkConnection.NickChanged was raised the args From property would already reflect the new nick. NetworkUser now subscribes to a new internal event that is raised after NetworkConnection.NickChanged. - Bug with wildcards in user hosts, processed correctly now. Added: - NetworkConnection.SendRawMessage(). Use to send a raw irc message. - NetworkConnection.SendKick(). Use to kick a user. - NetworkConnection.Kick event. Raised when a user is kicked from a channel. - NetworkUser.SendKick(). Use to kick this user from a channel. - NetworkUser.Kick event. Raised when the user is kicked from a channel. - User.ClearHosts(). Added to complete the User.*Host method set. Index: ChannelCollection.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/Irc/Collections/ChannelCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ChannelCollection.cs 16 Jan 2005 03:16:20 -0000 1.2 --- ChannelCollection.cs 28 Feb 2005 00:10:41 -0000 1.3 *************** *** 34,37 **** --- 34,42 ---- get { return (m_Table[name] as NetworkChannel); } } + + public int Count + { + get { return m_Table.Count; } + } public ICollection Keys |
From: Iain M. <iai...@us...> - 2005-02-28 00:10:50
|
Update of /cvsroot/bobbot/Bob/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16515/Core Modified Files: User.cs Log Message: Changed: - NetworkUser.Parse() made public. - NetworkConnection.Send(string rawMessage) now implemented. - Bot will try to rejoin a channel if it has been kicked. - When a user parts all known channels they are given 20 seconds to rejoin or a quit is raised for them. Fixed: - Bug in NetworkUser.Parse() where it would not correctly parse n!u@h without a leading colon. - Bug when NetworkConnection.NickChanged was raised the args From property would already reflect the new nick. NetworkUser now subscribes to a new internal event that is raised after NetworkConnection.NickChanged. - Bug with wildcards in user hosts, processed correctly now. Added: - NetworkConnection.SendRawMessage(). Use to send a raw irc message. - NetworkConnection.SendKick(). Use to kick a user. - NetworkConnection.Kick event. Raised when a user is kicked from a channel. - NetworkUser.SendKick(). Use to kick this user from a channel. - NetworkUser.Kick event. Raised when the user is kicked from a channel. - User.ClearHosts(). Added to complete the User.*Host method set. Index: User.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/User.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** User.cs 10 Jan 2005 01:39:55 -0000 1.4 --- User.cs 28 Feb 2005 00:10:40 -0000 1.5 *************** *** 151,154 **** --- 151,159 ---- } + public virtual void ClearHosts() + { + m_Hosts.Clear(); + } + public virtual bool HasHost(string host) { *************** *** 158,169 **** public virtual bool HasMatchingHost(string matchHost) { - Regex r = new Regex(matchHost.Replace("*", ".*"), RegexOptions.Singleline); - lock(m_Hosts) { ! foreach(string host in m_Hosts) ! { ! if(r.IsMatch(host.Replace("*", ".*"))) return true; } } --- 163,174 ---- public virtual bool HasMatchingHost(string matchHost) { lock(m_Hosts) { ! foreach(string host in m_Hosts) { ! Regex r = new Regex(host.Replace("*", ".*"), RegexOptions.Compiled | RegexOptions.Singleline); ! ! if(r.IsMatch(matchHost)) { return true; + } } } |
From: Iain M. <iai...@us...> - 2005-02-28 00:10:50
|
Update of /cvsroot/bobbot/Bob/Core/Irc/Messages/Commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16515/Core/Irc/Messages/Commands Modified Files: PrivateMessage.cs Log Message: Changed: - NetworkUser.Parse() made public. - NetworkConnection.Send(string rawMessage) now implemented. - Bot will try to rejoin a channel if it has been kicked. - When a user parts all known channels they are given 20 seconds to rejoin or a quit is raised for them. Fixed: - Bug in NetworkUser.Parse() where it would not correctly parse n!u@h without a leading colon. - Bug when NetworkConnection.NickChanged was raised the args From property would already reflect the new nick. NetworkUser now subscribes to a new internal event that is raised after NetworkConnection.NickChanged. - Bug with wildcards in user hosts, processed correctly now. Added: - NetworkConnection.SendRawMessage(). Use to send a raw irc message. - NetworkConnection.SendKick(). Use to kick a user. - NetworkConnection.Kick event. Raised when a user is kicked from a channel. - NetworkUser.SendKick(). Use to kick this user from a channel. - NetworkUser.Kick event. Raised when the user is kicked from a channel. - User.ClearHosts(). Added to complete the User.*Host method set. Index: PrivateMessage.cs =================================================================== RCS file: /cvsroot/bobbot/Bob/Core/Irc/Messages/Commands/PrivateMessage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrivateMessage.cs 9 Dec 2004 19:43:18 -0000 1.1 --- PrivateMessage.cs 28 Feb 2005 00:10:41 -0000 1.2 *************** *** 68,72 **** public PrivateMessage(NetworkUser dest, string msg) : base() { ! Parameters.Add(dest.Nickname); Parameters.Add(msg); } --- 68,72 ---- public PrivateMessage(NetworkUser dest, string msg) : base() { ! Parameters.Add(dest.ToString()); Parameters.Add(msg); } |
From: Mr S. C. <mrs...@us...> - 2005-02-26 22:42:52
|
Update of /cvsroot/bobbot/Plugins/Sphere/Accounting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20077/Sphere/Accounting Modified Files: AccountRegistration.cs Log Message: - *shrugs* Index: AccountRegistration.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/Accounting/AccountRegistration.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AccountRegistration.cs 4 Jan 2005 23:22:15 -0000 1.3 --- AccountRegistration.cs 26 Feb 2005 22:42:43 -0000 1.4 *************** *** 87,91 **** --- 87,93 ---- { if (!AccountExists(account)) + { return null; + } string password = (string)m_Server.GetAccountProperty(account, "password"); |
From: Mr S. C. <mrs...@us...> - 2005-02-26 22:41:47
|
Update of /cvsroot/bobbot/Plugins/Sphere/LogManagement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19760/Sphere/LogManagement Modified Files: LogManager.cs Log Message: - Who knows what's changed here... I forget :D Index: LogManager.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/LogManagement/LogManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LogManager.cs 21 Feb 2005 03:51:11 -0000 1.5 --- LogManager.cs 26 Feb 2005 22:41:38 -0000 1.6 *************** *** 74,106 **** } - public string CreateMessage(LogEntry entry) - { - string handle = ""; - if (entry.Handled) - handle = String.Format("{0}(Handled by {1}){0}", "", entry.HandledBy); - - if (entry.Entry is ClientPageMessage) - { - ClientPageMessage msg = (ClientPageMessage)entry.Entry; - return String.Format("{0} {1} Page from {2} [{3}] at {4}: {5}", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.Character, msg.Serial, msg.Position.ToString(), msg.Page); - } - else if (entry.Entry is HouseKillingMessage) - { - HouseKillingMessage msg = (HouseKillingMessage)entry.Entry; - return String.Format("{0} House Killing. {1} Victim={2}(Name={3} Position={4}) Aggressor={5}(Name={6} Position={7})", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.VictimUid, msg.VictimName, msg.VictimP, msg.AggressorUid, msg.AggressorName, msg.AggressorP); - } - else if (entry.Entry is SkillNukeMessage) - { - SkillNukeMessage msg = (SkillNukeMessage)entry.Entry; - return String.Format("{0} Skill Nuke. {1} Player={2}({3}). Skill={4} (Before Nuke: {5})", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.Name, msg.Account, msg.SkillName, msg.SkillBefore); - } - else if (entry.Entry is RideLostMessage) - { - RideLostMessage msg = (RideLostMessage)entry.Entry; - return String.Format("{0} Ride Lost. {1} Type=0{2:x} Serial=0{3:x} Name={4}", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.ID, msg.Serial, msg.Name); - } - return null; - } - #endregion --- 74,77 ---- *************** *** 125,134 **** Bot.Other.Sphere.Messages.BaseMessage msg = SphereConnection.Instance.ParseMessage( args.Message ); ! if (msg is ClientPageMessage) ! m_LogEntries.Add(new LogEntry(msg, args.Message)); ! ! else if (msg is HouseKillingMessage) { ! if (!RawMessageFound(args.Message, ((HouseKillingMessage)msg).Time)) m_LogEntries.Add(new LogEntry(msg, args.Message)); } --- 96,102 ---- Bot.Other.Sphere.Messages.BaseMessage msg = SphereConnection.Instance.ParseMessage( args.Message ); ! if (msg is HouseKillingMessage) { ! if (!RawMessageFound(args.Message))//, ((HouseKillingMessage)msg).Time)) m_LogEntries.Add(new LogEntry(msg, args.Message)); } *************** *** 287,295 **** } ! public bool RawMessageFound(string message, DateTime date) { foreach (LogEntry entry in m_LogEntries) { ! if (entry.RawString.ToLower() == message.ToLower() && date == entry.Time) return true; } --- 255,263 ---- } ! public bool RawMessageFound(string message)//, DateTime date) { foreach (LogEntry entry in m_LogEntries) { ! if (entry.RawString.ToLower() == message.ToLower())// && date == entry.Time) return true; } *************** *** 298,301 **** --- 266,293 ---- } + public string CreateMessage(LogEntry entry) + { + string handle = ""; + if (entry.Handled) + handle = String.Format("{0}(Handled by {1}){0}", "", entry.HandledBy); + + if (entry.Entry is HouseKillingMessage) + { + HouseKillingMessage msg = (HouseKillingMessage)entry.Entry; + return String.Format("{0} House Killing. {1} Victim={2}(Name={3} Position={4}) Aggressor={5}(Name={6} Position={7})", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.VictimUid, msg.VictimName, msg.VictimP, msg.AggressorUid, msg.AggressorName, msg.AggressorP); + } + else if (entry.Entry is SkillNukeMessage) + { + SkillNukeMessage msg = (SkillNukeMessage)entry.Entry; + return String.Format("{0} Skill Nuke. {1} Player={2}({3}). Skill={4} (Before Nuke: {5})", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.Name, msg.Account, msg.SkillName, msg.SkillBefore); + } + else if (entry.Entry is RideLostMessage) + { + RideLostMessage msg = (RideLostMessage)entry.Entry; + return String.Format("{0} Ride Lost. {1} Type=0{2:x} Serial=0{3:x} Name={4}", entry.Time.ToString("[dd/MM/yy - hh:mm]"), handle, msg.ID, msg.Serial, msg.Name); + } + return null; + } + #endregion } |
From: Mr S. C. <mrs...@us...> - 2005-02-21 03:52:19
|
Update of /cvsroot/bobbot/Plugins/Sphere/Messages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5748/Sphere/Messages Modified Files: HouseKillingMessage.cs Log Message: - Updated the HouseKillingMessage to only include messages marked as Confirmed from the Sphere Server. Index: HouseKillingMessage.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/Messages/HouseKillingMessage.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HouseKillingMessage.cs 20 Feb 2005 18:41:34 -0000 1.2 --- HouseKillingMessage.cs 21 Feb 2005 03:52:11 -0000 1.3 *************** *** 42,46 **** protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):\((.+)\)(.+) house killing\? \(Victim=(.+) Uid=(.+) P=(.+) \((.+)\), Aggressor=(.+) Uid=(.+) P=(.+) \((.+)\)\)", RegexOptions.Compiled ); --- 42,46 ---- protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):\((.+)\)\(Confirmed\) (.+) house killing\? \(Victim=(.+) Uid=(.+) P=(.+) \((.+)\), Aggressor=(.+) Uid=(.+) P=(.+) \((.+)\)\)", RegexOptions.Compiled ); *************** *** 55,59 **** protected string m_AggressorName; protected string m_AggressorUid; ! protected string m_AggresorP; #endregion --- 55,59 ---- protected string m_AggressorName; protected string m_AggressorUid; ! protected string m_AggressorP; #endregion *************** *** 85,89 **** public string VictimP { ! get { return m_VictimName; } } --- 85,89 ---- public string VictimP { ! get { return m_VictimP; } } *************** *** 100,104 **** public string AggressorP { ! get { return m_AggressorName; } } --- 100,104 ---- public string AggressorP { ! get { return m_AggressorP; } } *************** *** 136,140 **** m_AggressorName = match.Groups[8].Value; m_AggressorUid = match.Groups[9].Value; ! m_AggresorP = String.Format("{0} ({1})", match.Groups[10].Value, match.Groups[11].Value); } --- 136,140 ---- m_AggressorName = match.Groups[8].Value; m_AggressorUid = match.Groups[9].Value; ! m_AggressorP = String.Format("{0} ({1})", match.Groups[10].Value, match.Groups[11].Value); } |
From: Mr S. C. <mrs...@us...> - 2005-02-21 03:51:21
|
Update of /cvsroot/bobbot/Plugins/Sphere/LogManagement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5525/Sphere/LogManagement Modified Files: LogManager.cs Log Message: - Duplicate HouseKillingMessage won't be added to the database (Re-Added) Index: LogManager.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/LogManagement/LogManager.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LogManager.cs 17 Feb 2005 03:07:03 -0000 1.4 --- LogManager.cs 21 Feb 2005 03:51:11 -0000 1.5 *************** *** 69,75 **** server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); ! server.ClientPage += new ClientPageEventHandler(OnClientPage); ! server.RideLost += new RideLostEventHandler(OnRideLost); ! server.CustomEvent += new EventHandler(OnCustomEvent); } --- 69,75 ---- server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); ! //server.ClientPage += new ClientPageEventHandler(OnClientPage); ! //server.RideLost += new RideLostEventHandler(OnRideLost); ! //server.CustomEvent += new EventHandler(OnCustomEvent); } *************** *** 123,128 **** } ! } private void OnClientPage(object sender, ClientPageEventArgs args) { --- 123,147 ---- } ! Bot.Other.Sphere.Messages.BaseMessage msg = SphereConnection.Instance.ParseMessage( args.Message ); + if (msg is ClientPageMessage) + m_LogEntries.Add(new LogEntry(msg, args.Message)); + + else if (msg is HouseKillingMessage) + { + if (!RawMessageFound(args.Message, ((HouseKillingMessage)msg).Time)) + m_LogEntries.Add(new LogEntry(msg, args.Message)); + } + + else if (msg is RideLostMessage) + m_LogEntries.Add(new LogEntry(msg, args.Message)); + + else if (msg is SkillNukeMessage) + m_LogEntries.Add(new LogEntry(msg, args.Message)); + + + + } + /* private void OnClientPage(object sender, ClientPageEventArgs args) { *************** *** 155,159 **** OnSkillNuke(sender, (SkillNukeEventArgs) args); } ! #endregion --- 174,178 ---- OnSkillNuke(sender, (SkillNukeEventArgs) args); } ! */ #endregion |
From: Mr S. C. <mrs...@us...> - 2005-02-20 18:41:48
|
Update of /cvsroot/bobbot/Plugins/Sphere/Messages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29569/Sphere/Messages Modified Files: HouseKillingMessage.cs PlayerJailedMessage.cs SkillNukeMessage.cs Log Message: - Updated the Custom Messages to reflect changes within the scripts on the Sphere Server. Index: SkillNukeMessage.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/Messages/SkillNukeMessage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SkillNukeMessage.cs 15 Feb 2005 21:53:10 -0000 1.1 --- SkillNukeMessage.cs 20 Feb 2005 18:41:34 -0000 1.2 *************** *** 42,46 **** protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):ERROR:\((.+)\)'(.+)' \((.+)\) nukes their (.+) skill from (.+)", RegexOptions.Compiled ); --- 42,46 ---- protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):\((.+)\)'(.+)' \((.+)\) nukes their (.+) skill from (.+)", RegexOptions.Compiled ); Index: HouseKillingMessage.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/Messages/HouseKillingMessage.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HouseKillingMessage.cs 15 Feb 2005 21:53:09 -0000 1.1 --- HouseKillingMessage.cs 20 Feb 2005 18:41:34 -0000 1.2 *************** *** 42,46 **** protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):ERROR:\((.+)\)(.+) house killing\? \(Victim=(.+) Uid=(.+) P=(.+) \((.+)\), Aggressor=(.+) Uid=(.+) P=(.+) \((.+)\)\)", RegexOptions.Compiled ); --- 42,46 ---- protected Regex m_Regex = new Regex( ! @"^([0-9]{2}:[0-9]{2}):\((.+)\)(.+) house killing\? \(Victim=(.+) Uid=(.+) P=(.+) \((.+)\), Aggressor=(.+) Uid=(.+) P=(.+) \((.+)\)\)", RegexOptions.Compiled ); Index: PlayerJailedMessage.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/Messages/PlayerJailedMessage.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlayerJailedMessage.cs 16 Jan 2005 01:24:00 -0000 1.2 --- PlayerJailedMessage.cs 20 Feb 2005 18:41:34 -0000 1.3 *************** *** 48,52 **** protected int m_GM; protected int m_Player; ! protected int m_Length; protected string m_Reason; #endregion --- 48,52 ---- protected int m_GM; protected int m_Player; ! protected string m_Length; protected string m_Reason; #endregion *************** *** 71,75 **** } ! public int Length { get { return m_Length; } --- 71,75 ---- } ! public string Length { get { return m_Length; } *************** *** 108,112 **** m_GM = Int32.Parse(match.Groups[2].Value, NumberStyles.AllowHexSpecifier); m_Player = Int32.Parse(match.Groups[3].Value, NumberStyles.AllowHexSpecifier); ! m_Length = Int32.Parse(match.Groups[4].Value); m_Reason = match.Groups[5].Value; } --- 108,112 ---- m_GM = Int32.Parse(match.Groups[2].Value, NumberStyles.AllowHexSpecifier); m_Player = Int32.Parse(match.Groups[3].Value, NumberStyles.AllowHexSpecifier); ! m_Length = match.Groups[4].Value; m_Reason = match.Groups[5].Value; } |
From: Mr S. C. <mrs...@us...> - 2005-02-17 03:07:21
|
Update of /cvsroot/bobbot/Plugins/Sphere In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/Sphere Modified Files: SpherePlugin.cs Log Message: Only 30 messages will be displayed using 'Log List <type>' PrivateCommand (Must be more specific and provide DateTimes to see further) Index: SpherePlugin.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/SpherePlugin.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SpherePlugin.cs 17 Feb 2005 02:29:29 -0000 1.18 --- SpherePlugin.cs 17 Feb 2005 03:07:04 -0000 1.19 *************** *** 7,11 **** } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Password: {1}", temp.Name, temp.Password); Kernel.Instance.Network.SendPrivateMessage(user, "Lang: {0} PLevel: {1}", temp.Lang, Account.PrivToString(temp.Plevel)); Kernel.Instance.Network.SendPrivateMessage(user, "FirstIP: {0} FirstDate: {1}", temp.FirstIP, temp.FirstConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "LastIP: {0} LastDate: {1}", temp.LastIP, temp.LastConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "Chars: {0} LastChar: 0{1:x}", temp.Chars, temp.LastCharUID); Kernel.Instance.Network.SendPrivateMessage(user, "TotalConnect: {0} LastConnect: {1}", temp.TotalConnectTime, temp.LastConnectTime); Kernel.Instance.Network.SendPrivateMessage(user, "Priv: 0{0:x}", temp.Priv); Kernel.Instance.Network.SendPrivateMessage(user, "Jailed: {0} Blocked: {1}", ((temp.Jailed)? "Yes" : "No"), ((temp.Blocked)? "Yes" : "No")); } return; } } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testitem")] private void testitemcommand(NetworkUser user, string[] args) { if (args.Length != 2) return; user.SendMessage("Value '{0}' for '{1}' is {2}", args[1], args[0], m_Server.GetItemProperty(Int32.Parse(args[0], System.Globalization.NumberStyles.HexNumber), args[1])); } [PrivateCommand("mypriv")] private void myprivcommand(NetworkUser user, string[] args) { user.SendNotice("Your priv is: {0}", Account.PrivToString(m_SphereAuth.GetStaffPriv(user))); return; } [PrivateCommand("liststaff")] private void liststaffcommand(NetworkUser user, string[] args) { foreach (Bot.Core.User staff in m_SphereAuth.StaffMembers()) user.SendNotice("{0}, {1}", staff.Name, Account.PrivToString((AccountPriv)staff.GetProperty("LothStaff"))); } [ChannelCommand("listchan")] private void ListChan(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "I am on the following channels:"); foreach(string channel in Kernel.Instance.Network.Channels.Keys) Kernel.Instance.Network.SendChannelMessage(chan, "\t\t{0}", channel); } #endregion #region 'Remote' Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [RemoteCommand("account")] private static void RemoteAccountCommand(RemoteConnection sender, string[] args) { if (args.Length < 2) { sender.Send("Invalid Command or Format."); return; } if (args[0].ToLower() == "add") switch (args.Length) { case 2: { if (AccountRegistration.Instance.AccountAdd(args[1])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } case 3: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } default: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2], Account.StringToPriv(args[3]))) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } } else if (args[1].ToLower() == "delete") { if (AccountRegistration.Instance.AccountDel(args[0])) sender.Send("Account {0} deleted!", args[0]); else sender.Send("Unable to delete account!"); return; } else { string[] function = new string[ args.Length - 1 ]; Array.Copy(args, 1, function, 0, function.Length); sender.Send(AccountRegistration.Instance.AccountMod(args[0], function)); } } #endregion #region 'Staff' Commands #region Connection Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!recon")] private void ReconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); if (args.Length <= 0) m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); else m_Server.Connect(IPAddress.Parse(args[0]), m_Config.Port); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!discon")] private void DisconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); else chan.SendMessage("Not Connected To Server."); } #endregion #region Misc Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!resync")] private void ResyncCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } m_Server.WriteLine("r"); m_Server.WriteLine("r"); chan.SendMessage("Done."); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcast")] private void BroadcastCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { chan.SendMessage("You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "Broadcast: {0}", message); Log.WriteLine("Sphere", "Broadcast:{0}", message); if (message.Length < 70) { m_Server.WriteLine("b" + message); } else { message = message.Trim(); while (message.Length > 70) { m_Server.WriteLine("b " + message.Substring(0, 70)); message = message.Remove(0, 70); } m_Server.WriteLine("b " + message); } } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcastirc")] private void BroadcastIrcCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "IRC Broadcast: {0}", message); Log.WriteLine("Sphere", "IRC Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!go")] private void GoCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 2) { chan.SendMessage("Usage: !Go <uid> <message>"); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) { if (i != args[0]) message += " " + i; } m_Server.WriteLine("var.lothbot_target={0}", args[0]); m_Server.WriteLine("uid.{0}.respondtoplayer {1}", m_LothBotUid, message.Trim()); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("admin listlog")] private void AdminListLogCommand(NetworkUser user, string[] args) { string[] logFiles = Directory.GetFiles(m_Config.LogDirectory, "*.log"); if(logFiles.Length == 0) { user.SendMessage("There are no log files available."); } else { user.SendMessage("The following log files are available:"); foreach(string log in logFiles) user.SendMessage("\t{0}", log); } } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("addstaff")] private void AddStaffCommand(NetworkUser user, string[] args) { if (args.Length < 1) { user.SendMessage("You must at least provide an account name."); return; } else if (args.Length > 3) { user.SendMessage("Too many arguments provided! (AddStaff <Account> [<Priv>] [<Password>]"); return; } if (!m_Server.IsConnected) { user.SendMessage("Unable to add accounts whilst not connected to the server!"); return; } switch (args.Length) { case 1: { if (m_Accounting.AccountAdd(args[0], AccountPriv.Counselor)) user.SendMessage("Counselor account '{0}' created successfully! Password is '{1}'", args[0], "blah"); else user.SendMessage("Unable to create account!"); return; } case 2: { if (m_Accounting.AccountAdd(args[0], Account.StringToPriv(args[1]))) user.SendMessage("{1} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), "blah"); else user.SendMessage("Unable to create account!"); return; } case 3: { if (m_Accounting.AccountAdd(args[0], args[2], Account.StringToPriv(args[1]))) user.SendMessage("{2} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), args[2]); else user.SendMessage("Unable to create account!"); return; } } } #endregion #region Jail Commands [PrivateCommand("jail")] private void JailCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Jail <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Add <Account> <Length> [<Reason>]'"); return; } if (m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' is already jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.Jail(args[1], null, user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}' jailed for {1} hours!", args[1], args[2]); else user.SendNotice("Unable to jail '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Del <Account>'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } if (m_JailSystem.Release(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Edit <Account> <Length> [<Reason>]'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.EditJail(args[1], user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}'s jail entry is edited!", args[1]); else user.SendNotice("Unable to edit jail entry '{0}'!", args[1]); return; } case "list": { if (m_JailSystem.JailedAccounts <= 0) { user.SendNotice("No Accounts are Jailed!"); return; } foreach (JailEntry entry in m_JailSystem.GetJailEntryList()) { user.SendNotice("Account: {0} Release Date: {1}", entry.Account, entry.JailedUntil.ToString()); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Info <Account>'"); return; } JailEntry entry = m_JailSystem.GetJailEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Jailed By: {0}", entry.JailedBy); user.SendNotice("Jail Date: {0}", entry.JailedOn); user.SendNotice("Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Jailed!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_JailSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Add <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new jail database entry for <Account>. The account will"); user.SendNotice("automatically be jailed ingame."); user.SendNotice("The release date will be set <Length> hours after the jail"); user.SendNotice("time, and will automatically released from jail at that time."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Jail Add myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Add myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically released ingame."); user.SendNotice("Example: /msg {0} Jail Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Edit <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the"); user.SendNotice("entry's length to <Length> hours."); user.SendNotice("If [<Reason>] is provided then this will also be amended."); user.SendNotice("The 'Jailed By' property of the jail entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice("Example: /msg {0} Jail Edit myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Edit myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Jail Database to be saved immediately. Unsaved jail"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Jail Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Jail List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently jailed accounts, along with"); user.SendNotice("their release dates. For more information on a jail entry, use"); user.SendNotice("Jail Info"); user.SendNotice("Example: /msg {0} Jail List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Jail Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s jail entry."); user.SendNotice("Example: /msg {0} Jail Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } } } #endregion #region Ban Commands [PrivateCommand("ban")] private void BanCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Ban <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Add <Account> [<Reason>]'"); return; } if (m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' is already banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.Ban(args[1], null, user.Nickname, banargs.Trim())) user.SendNotice("'{0}' banned!", args[1]); else user.SendNotice("Unable to ban '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Del <Account>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } if (m_BanSystem.UnBan(args[1], user.Nickname)) user.SendNotice("'{0}' unbanned!", args[1]); else user.SendNotice("Unable to unban '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Ban Edit <Account> <Reason>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.EditBan(args[1], user.Nickname, banargs.Trim())) user.SendNotice("'{0}'s ban entry is edited!", args[1]); else user.SendNotice("Unable to edit ban entry '{0}'!", args[1]); return; } case "list": { if (m_BanSystem.BannedAccounts <= 0) { user.SendNotice("No Accounts are Banned!"); return; } foreach (BanEntry entry in m_BanSystem.GetBanEntryList()) { user.SendNotice("Account: {0}", entry.Account); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Info <Account>'"); return; } BanEntry entry = m_BanSystem.GetBanEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Banned By: {0}", entry.BannedBy); user.SendNotice("Ban Date: {0}", entry.BannedOn); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Banned!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_BanSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Add <Account> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new ban database entry for <Account>. The account will"); user.SendNotice("automatically be banned ingame."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Ban Add myAccount", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Ban Add myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically be unbanned ingame."); user.SendNotice("Example: /msg {0} Ban Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Edit <Account> <Reason>", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the."); user.SendNotice("current Reason to <Reason>."); user.SendNotice("The 'Banned By' property of the ban entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice(" /msg {0} Ban Edit myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Ban Database to be saved immediately. Unsaved ban"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Ban Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Ban List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently banned accounts, along with"); user.SendNotice("their release dates. For more information on a ban entry, use"); user.SendNotice("Ban Info"); user.SendNotice("Example: /msg {0} Ban List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Ban Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s ban entry."); user.SendNotice("Example: /msg {0} Ban Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } } } #endregion #region Page Commands [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!pages")] private void PagesCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages <= 0) { user.SendNotice("There are no pages to list!"); return; } user.SendNotice("Pages: {0}", pages); for (int i = 0; i < pages; i++) { user.SendNotice( "{0}. Time=\"{1} minutes ago\" Account=\"{2}\" Reason=\"{3}\"", (i + 1), (Int32.Parse((string)m_Server.GetProperty(String.Format("GMPAGE.{0}.TIME", i)), System.Globalization.NumberStyles.HexNumber) / 60), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.ACCOUNT", i)), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.REASON", i)) ); } } [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!page delete")] private void PageCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } if (args.Length <= 0) { PagesCommand(chan, user, args); return; } int page; try {page = Int32.Parse(args[0]) - 1; } catch { return; } if (page < 0) { chan.SendMessage("You must specify a page number greater than 0."); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages < page) { chan.SendMessage("This page doesn't exist!"); return; } m_Server.WriteLine("GMPAGE.{0}.DELETE", page); chan.SendMessage("Page deleted."); } #endregion #region Log Manager Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [PrivateCommand("log")] private void LogCommand(NetworkUser user, string[] args) { if (args.Length <= 1) { user.SendMessage("Usage: Log <command> <type> [<args>]"); return; } switch (args[0].ToLower()) { #region Log List case "list": { DateTime from = DateTime.Parse("01/01/1900"); DateTime to = DateTime.Parse("01/01/3000"); Type logtype; try ! { if (args.Length >= 3) from = DateTime.Parse(args[2]); if (args.Length >= 4) to = DateTime.Parse(args[3]); } catch { user.SendMessage("Invalid Date/Time(s)."); return; } switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); foreach (LogEntry entry in m_LogManager.GetEntriesBetweenTimes(from, to)) { if (entry.Type == logtype) entries.Add( entry ); /*else { Console.WriteLine(); Console.WriteLine("MESSAGE: {0}", entry.RawString); Console.WriteLine("TYPE: {0}", entry.Type.FullName); }*/ } if (entries.Count <= 0) { user.SendMessage("No log messages found."); return; } for (int i = 0; i < entries.Count; i++) { user.SendMessage("{0}. {1}", (i + 1), m_LogManager.CreateMessage( (LogEntry)entries[i] )); } return; } #endregion #region Log Handle case "handle": { if (args.Length < 3) { user.SendMessage("Usage: Log Handle <type> <lognumber>"); return; } Type logtype; switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); foreach (LogEntry entry in m_LogManager.LogEntries) { if (entry.Type == logtype) entries.Add( entry ); } int index; try { index = Int32.Parse(args[2]) - 1; } catch { user.SendMessage("Unknown index format. index should be an integer."); return; } if (index < 0 || index >= entries.Count) { user.SendMessage("Selected message does not exist!"); return; } if (((LogEntry)entries[index]).Handled) { user.SendMessage("This message has already been handled by '{0}'", ((LogEntry)entries[index]).HandledBy); return; } if (args.Length < 4 || args[3] != "1") { user.SendMessage("Confirm Handle: Log Handle <type> <log number> 1"); user.SendMessage("{0}. {1}", index + 1, m_LogManager.CreateMessage( (LogEntry)entries[index] )); return; } for (int i = 0; i < m_LogManager.LogEntries.Length; i++) { if (m_LogManager.LogEntries[i].RawString != ((LogEntry)entries[index]).RawString) continue; else if (m_LogManager.LogEntries[i].Time != ((LogEntry)entries[index]).Time) continue; m_LogManager.LogEntries[i].Handle(user.Nickname); user.SendMessage("Log Message Handled: {0}", m_LogManager.CreateMessage( (LogEntry)entries[index] )); return; } user.SendMessage("Unable to mark message as handled."); break; } #endregion #region Log Del case "del": { if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) { user.SendMessage("Only Administrators can delete log messages."); return; } if (args.Length < 3) { user.SendMessage("Usage: Log Del <type> <lognumber>"); return; } Type logtype; switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); foreach (LogEntry entry in m_LogManager.LogEntries) { if (entry.Type == logtype) entries.Add( entry ); } int index; try { index = Int32.Parse(args[2]) - 1; } catch { user.SendMessage("Unknown index format. index should be an integer."); return; } if (index < 0 || index >= entries.Count) { user.SendMessage("Selected message does not exist!"); return; } if (args.Length < 4 || args[3] != "1") { user.SendMessage("Confirm Delete: Log Del <type> <log number> 1"); user.SendMessage("{0}. {1}", index + 1, m_LogManager.CreateMessage( (LogEntry)entries[index] )); return; } for (int i = 0; i < m_LogManager.LogEntries.Length; i++) { if (m_LogManager.LogEntries[i].RawString != ((LogEntry)entries[index]).RawString) continue; else if (m_LogManager.LogEntries[i].Time != ((LogEntry)entries[index]).Time) continue; if (m_LogManager.DeleteEntry(i)) user.SendMessage("Log Message Deleted: {0}", m_LogManager.CreateMessage( (LogEntry)entries[index] )); else user.SendMessage("Unable to delete message."); return; } user.SendMessage("Unable to delete message."); break; } #endregion #region Log Save case "save": { if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) { user.SendMessage("Only Administrators can delete log messages."); return; } if (m_LogManager.SaveDatabase()) user.SendMessage("Database Saved."); else user.SendMessage("Database failed to save!"); break; } #endregion default: { user.SendMessage("Unknown Command. Use 'list', 'handle', 'del' or 'save'."); return; } } } #endregion #endregion #region 'Player' Commands [ChannelCommand("!stats")] private void StatsCommand(NetworkChannel chan, NetworkUser user, string[] args) { user.SendNotice("Peak Clients: {0}", SphereConnection.Instance.ClientCount); user.SendNotice("Players Connected: {0}", m_ConnectCount); user.SendNotice("Players Died: {0}", m_KillCount); user.SendNotice("Pages Received: {0}", m_PageCount); user.SendNotice("Commands Issued: {0}", m_ClientCommandsCount); user.SendNotice("World Saves: {0}", m_WorldSaveCount); } [ChannelCommand("!clients")] private void ClientsCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } chan.SendMessage(String.Format("The current client count is {0}", SphereConnection.Instance.ClientCount)); } [ChannelCommand("!status")] private void StatusCommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage(String.Format("Connection Status: {0} ({1}:{2}) - http://{1}:{2}/status.html", (m_Server.IsConnected) ? "Connected" : "Not Connected", m_Config.Address, m_Config.Port)); } [ChannelCommand("!jail")] private void JailCommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage("The Lothlorien Jail List is: http://bans.wireplay.co.uk/bans/game/52"); //user.SendNotice("The Jail Database is currently down. Please use \"/msg {0} Jail List\" and \"/msg {0} Ban List\" to view the jail database.", Kernel.Instance.Network.Nickname); } [ChannelCommand("!forum")] private void ForumCommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage("Forums for Lothlorien can be found at http://forums.wireplay.co.uk/forumdisplay.php3?forumid=299"); } [ChannelCommand("!url")] private void UrlCommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage("The Lothlorien website can be found at http://Lothlorien.wireplay.co.uk"); } [ChannelCommand("!uoa")] private void UOACommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage("UO Assist Key: tN2qD8,$MEd8,=je,4XrG,V}}9d,2fK]j,[Tu~,TXYK,+r"); } [ChannelCommand("!lastkill")] private void LastKillCommand(NetworkChannel chan, NetworkUser user, string[] args) { string m_Killers = ""; for (int i = 0; i < m_LastKillers.Length; i++) m_Killers += String.Format(" 5({0}) {1},", (m_LastKillers[i].Type == MobileType.Player? "Player":"Monster"), m_LastKillers[i].Name); m_Killers = m_Killers.Substring(0, m_Killers.Length - 1); chan.SendMessage("12({0}) {1} was killed by {2}", (m_LastVictim.Type == MobileType.Player)? "Player" : "NPC", m_LastVictim.Name, m_Killers.Trim().Length <= 0? m_LastVictim.Name : m_Killers.Trim()); } [ChannelCommand("!peak")] private void PeakCommand(NetworkChannel chan, NetworkUser user, string[] args) { chan.SendMessage("The peak clients is {0}", m_ClientPeak); } #endregion private void OnNetworkWelcome(NetworkConnection network, WelcomeReplyEventArgs args) --- 7,11 ---- } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Password: {1}", temp.Name, temp.Password); Kernel.Instance.Network.SendPrivateMessage(user, "Lang: {0} PLevel: {1}", temp.Lang, Account.PrivToString(temp.Plevel)); Kernel.Instance.Network.SendPrivateMessage(user, "FirstIP: {0} FirstDate: {1}", temp.FirstIP, temp.FirstConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "LastIP: {0} LastDate: {1}", temp.LastIP, temp.LastConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "Chars: {0} LastChar: 0{1:x}", temp.Chars, temp.LastCharUID); Kernel.Instance.Network.SendPrivateMessage(user, "TotalConnect: {0} LastConnect: {1}", temp.TotalConnectTime, temp.LastConnectTime); Kernel.Instance.Network.SendPrivateMessage(user, "Priv: 0{0:x}", temp.Priv); Kernel.Instance.Network.SendPrivateMessage(user, "Jailed: {0} Blocked: {1}", ((temp.Jailed)? "Yes" : "No"), ((temp.Blocked)? "Yes" : "No")); } return; } } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testitem")] private void testitemcommand(NetworkUser user, string[] args) { if (args.Length != 2) return; user.SendMessage("Value '{0}' for '{1}' is {2}", args[1], args[0], m_Server.GetItemProperty(Int32.Parse(args[0], System.Globalization.NumberStyles.HexNumber), args[1])); } [PrivateCommand("mypriv")] private void myprivcommand(NetworkUser user, string[] args) { user.SendNotice("Your priv is: {0}", Account.PrivToString(m_SphereAuth.GetStaffPriv(user))); return; } [PrivateCommand("liststaff")] private void liststaffcommand(NetworkUser user, string[] args) { foreach (Bot.Core.User staff in m_SphereAuth.StaffMembers()) user.SendNotice("{0}, {1}", staff.Name, Account.PrivToString((AccountPriv)staff.GetProperty("LothStaff"))); } [ChannelCommand("listchan")] private void ListChan(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "I am on the following channels:"); foreach(string channel in Kernel.Instance.Network.Channels.Keys) Kernel.Instance.Network.SendChannelMessage(chan, "\t\t{0}", channel); } #endregion #region 'Remote' Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [RemoteCommand("account")] private static void RemoteAccountCommand(RemoteConnection sender, string[] args) { if (args.Length < 2) { sender.Send("Invalid Command or Format."); return; } if (args[0].ToLower() == "add") switch (args.Length) { case 2: { if (AccountRegistration.Instance.AccountAdd(args[1])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } case 3: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } default: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2], Account.StringToPriv(args[3]))) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } } else if (args[1].ToLower() == "delete") { if (AccountRegistration.Instance.AccountDel(args[0])) sender.Send("Account {0} deleted!", args[0]); else sender.Send("Unable to delete account!"); return; } else { string[] function = new string[ args.Length - 1 ]; Array.Copy(args, 1, function, 0, function.Length); sender.Send(AccountRegistration.Instance.AccountMod(args[0], function)); } } #endregion #region 'Staff' Commands #region Connection Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!recon")] private void ReconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); if (args.Length <= 0) m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); else m_Server.Connect(IPAddress.Parse(args[0]), m_Config.Port); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!discon")] private void DisconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); else chan.SendMessage("Not Connected To Server."); } #endregion #region Misc Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!resync")] private void ResyncCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } m_Server.WriteLine("r"); m_Server.WriteLine("r"); chan.SendMessage("Done."); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcast")] private void BroadcastCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { chan.SendMessage("You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "Broadcast: {0}", message); Log.WriteLine("Sphere", "Broadcast:{0}", message); if (message.Length < 70) { m_Server.WriteLine("b" + message); } else { message = message.Trim(); while (message.Length > 70) { m_Server.WriteLine("b " + message.Substring(0, 70)); message = message.Remove(0, 70); } m_Server.WriteLine("b " + message); } } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcastirc")] private void BroadcastIrcCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "IRC Broadcast: {0}", message); Log.WriteLine("Sphere", "IRC Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!go")] private void GoCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 2) { chan.SendMessage("Usage: !Go <uid> <message>"); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) { if (i != args[0]) message += " " + i; } m_Server.WriteLine("var.lothbot_target={0}", args[0]); m_Server.WriteLine("uid.{0}.respondtoplayer {1}", m_LothBotUid, message.Trim()); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("admin listlog")] private void AdminListLogCommand(NetworkUser user, string[] args) { string[] logFiles = Directory.GetFiles(m_Config.LogDirectory, "*.log"); if(logFiles.Length == 0) { user.SendMessage("There are no log files available."); } else { user.SendMessage("The following log files are available:"); foreach(string log in logFiles) user.SendMessage("\t{0}", log); } } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("addstaff")] private void AddStaffCommand(NetworkUser user, string[] args) { if (args.Length < 1) { user.SendMessage("You must at least provide an account name."); return; } else if (args.Length > 3) { user.SendMessage("Too many arguments provided! (AddStaff <Account> [<Priv>] [<Password>]"); return; } if (!m_Server.IsConnected) { user.SendMessage("Unable to add accounts whilst not connected to the server!"); return; } switch (args.Length) { case 1: { if (m_Accounting.AccountAdd(args[0], AccountPriv.Counselor)) user.SendMessage("Counselor account '{0}' created successfully! Password is '{1}'", args[0], "blah"); else user.SendMessage("Unable to create account!"); return; } case 2: { if (m_Accounting.AccountAdd(args[0], Account.StringToPriv(args[1]))) user.SendMessage("{1} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), "blah"); else user.SendMessage("Unable to create account!"); return; } case 3: { if (m_Accounting.AccountAdd(args[0], args[2], Account.StringToPriv(args[1]))) user.SendMessage("{2} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), args[2]); else user.SendMessage("Unable to create account!"); return; } } } #endregion #region Jail Commands [PrivateCommand("jail")] private void JailCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Jail <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Add <Account> <Length> [<Reason>]'"); return; } if (m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' is already jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.Jail(args[1], null, user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}' jailed for {1} hours!", args[1], args[2]); else user.SendNotice("Unable to jail '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Del <Account>'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } if (m_JailSystem.Release(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Edit <Account> <Length> [<Reason>]'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.EditJail(args[1], user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}'s jail entry is edited!", args[1]); else user.SendNotice("Unable to edit jail entry '{0}'!", args[1]); return; } case "list": { if (m_JailSystem.JailedAccounts <= 0) { user.SendNotice("No Accounts are Jailed!"); return; } foreach (JailEntry entry in m_JailSystem.GetJailEntryList()) { user.SendNotice("Account: {0} Release Date: {1}", entry.Account, entry.JailedUntil.ToString()); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Info <Account>'"); return; } JailEntry entry = m_JailSystem.GetJailEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Jailed By: {0}", entry.JailedBy); user.SendNotice("Jail Date: {0}", entry.JailedOn); user.SendNotice("Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Jailed!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_JailSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) ... [truncated message content] |
From: Mr S. C. <mrs...@us...> - 2005-02-17 03:07:12
|
Update of /cvsroot/bobbot/Plugins/Sphere/LogManagement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/Sphere/LogManagement Modified Files: LogManager.cs Log Message: Only 30 messages will be displayed using 'Log List <type>' PrivateCommand (Must be more specific and provide DateTimes to see further) Index: LogManager.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/LogManagement/LogManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LogManager.cs 17 Feb 2005 02:48:34 -0000 1.3 --- LogManager.cs 17 Feb 2005 03:07:03 -0000 1.4 *************** *** 152,156 **** if (args is HouseKillingEventArgs) OnHouseKilling(sender, (HouseKillingEventArgs) args); ! else if (args is SkillNukeMessage) OnSkillNuke(sender, (SkillNukeEventArgs) args); } --- 152,156 ---- if (args is HouseKillingEventArgs) OnHouseKilling(sender, (HouseKillingEventArgs) args); ! else if (args is SkillNukeEventArgs) OnSkillNuke(sender, (SkillNukeEventArgs) args); } |
From: Mr S. C. <mrs...@us...> - 2005-02-17 02:48:43
|
Update of /cvsroot/bobbot/Plugins/Sphere/LogManagement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4071/Sphere/LogManagement Modified Files: LogManager.cs Log Message: SkillNukeMessages are now recorded by the LogManager Index: LogManager.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/LogManagement/LogManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LogManager.cs 17 Feb 2005 02:29:28 -0000 1.2 --- LogManager.cs 17 Feb 2005 02:48:34 -0000 1.3 *************** *** 143,150 **** --- 143,157 ---- } + private void OnSkillNuke(object sender, SkillNukeEventArgs args) + { + m_LogEntries.Add(new LogEntry(args.Message, m_LastMessage)); + } + private void OnCustomEvent(object sender, EventArgs args) { if (args is HouseKillingEventArgs) OnHouseKilling(sender, (HouseKillingEventArgs) args); + else if (args is SkillNukeMessage) + OnSkillNuke(sender, (SkillNukeEventArgs) args); } |
From: Mr S. C. <mrs...@us...> - 2005-02-17 02:29:38
|
Update of /cvsroot/bobbot/Plugins/Sphere In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31600/Sphere Modified Files: SpherePlugin.cs Log Message: Added a check to ensure an Account was retrieved when attempt to jail one. !stats now shows the correct number of pages. LogManager won't store duplicate housekill messages. (Work being done on scripts to reduce the overall amount of these being produced) Index: SpherePlugin.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/SpherePlugin.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SpherePlugin.cs 15 Feb 2005 23:52:45 -0000 1.17 --- SpherePlugin.cs 17 Feb 2005 02:29:29 -0000 1.18 *************** *** 1,3 **** ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Plugins.Sphere.LogManagement; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private LogManager m_LogManager; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_Server.ClientConnected += new ClientConnectedEventHandler(OnClientConnected); m_Server.RegisterHandler(typeof(HouseKillingMessage)); m_Server.RegisterHandler(typeof(PlayerJailedMessage)); m_Server.RegisterHandler(typeof(PlayerReleasedMessage)); m_Server.RegisterHandler(typeof(SkillNukeMessage)); Bot.Core.Kernel.Instance.Network.Welcome += new WelcomeReplyEventHandler(OnNetworkWelcome); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); m_LogManager = new LogManager(m_Server, m_Config.LogDatabase); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); //Log.WriteLine("Sphere", args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem.SaveDatabase(); m_BanSystem.SaveDatabase(); m_LogManager.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } private void OnClientConnected(object sender, ClientConnectedEventArgs args) --- 1,3 ---- ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Plugins.Sphere.LogManagement; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private LogManager m_LogManager; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_Server.ClientConnected += new ClientConnectedEventHandler(OnClientConnected); m_Server.RegisterHandler(typeof(HouseKillingMessage)); m_Server.RegisterHandler(typeof(PlayerJailedMessage)); m_Server.RegisterHandler(typeof(PlayerReleasedMessage)); m_Server.RegisterHandler(typeof(SkillNukeMessage)); Bot.Core.Kernel.Instance.Network.Welcome += new WelcomeReplyEventHandler(OnNetworkWelcome); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); m_LogManager = new LogManager(m_Server, m_Config.LogDatabase); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { m_PageCount++; Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem.SaveDatabase(); m_BanSystem.SaveDatabase(); m_LogManager.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } private void OnClientConnected(object sender, ClientConnectedEventArgs args) *************** *** 7,11 **** } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Password: {1}", temp.Name, temp.Password); Kernel.Instance.Network.SendPrivateMessage(user, "Lang: {0} PLevel: {1}", temp.Lang, Account.PrivToString(temp.Plevel)); Kernel.Instance.Network.SendPrivateMessage(user, "FirstIP: {0} FirstDate: {1}", temp.FirstIP, temp.FirstConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "LastIP: {0} LastDate: {1}", temp.LastIP, temp.LastConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "Chars: {0} LastChar: 0{1:x}", temp.Chars, temp.LastCharUID); Kernel.Instance.Network.SendPrivateMessage(user, "TotalConnect: {0} LastConnect: {1}", temp.TotalConnectTime, temp.LastConnectTime); Kernel.Instance.Network.SendPrivateMessage(user, "Priv: 0{0:x}", temp.Priv); Kernel.Instance.Network.SendPrivateMessage(user, "Jailed: {0} Blocked: {1}", ((temp.Jailed)? "Yes" : "No"), ((temp.Blocked)? "Yes" : "No")); } return; } } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testitem")] private void testitemcommand(NetworkUser user, string[] args) { if (args.Length != 2) return; user.SendMessage("Value '{0}' for '{1}' is {2}", args[1], args[0], m_Server.GetItemProperty(Int32.Parse(args[0], System.Globalization.NumberStyles.HexNumber), args[1])); } [PrivateCommand("mypriv")] private void myprivcommand(NetworkUser user, string[] args) { user.SendNotice("Your priv is: {0}", Account.PrivToString(m_SphereAuth.GetStaffPriv(user))); return; } [PrivateCommand("liststaff")] private void liststaffcommand(NetworkUser user, string[] args) { foreach (Bot.Core.User staff in m_SphereAuth.StaffMembers()) user.SendNotice("{0}, {1}", staff.Name, Account.PrivToString((AccountPriv)staff.GetProperty("LothStaff"))); } [ChannelCommand("listchan")] private void ListChan(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "I am on the following channels:"); foreach(string channel in Kernel.Instance.Network.Channels.Keys) Kernel.Instance.Network.SendChannelMessage(chan, "\t\t{0}", channel); } #endregion #region 'Remote' Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [RemoteCommand("account")] private static void RemoteAccountCommand(RemoteConnection sender, string[] args) { if (args.Length < 2) { sender.Send("Invalid Command or Format."); return; } if (args[0].ToLower() == "add") switch (args.Length) { case 2: { if (AccountRegistration.Instance.AccountAdd(args[1])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } case 3: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } default: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2], Account.StringToPriv(args[3]))) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } } else if (args[1].ToLower() == "delete") { if (AccountRegistration.Instance.AccountDel(args[0])) sender.Send("Account {0} deleted!", args[0]); else sender.Send("Unable to delete account!"); return; } else { string[] function = new string[ args.Length - 1 ]; Array.Copy(args, 1, function, 0, function.Length); sender.Send(AccountRegistration.Instance.AccountMod(args[0], function)); } } #endregion #region 'Staff' Commands #region Connection Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!recon")] private void ReconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); if (args.Length <= 0) m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); else m_Server.Connect(IPAddress.Parse(args[0]), m_Config.Port); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!discon")] private void DisconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); else chan.SendMessage("Not Connected To Server."); } #endregion #region Misc Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!resync")] private void ResyncCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } m_Server.WriteLine("r"); m_Server.WriteLine("r"); chan.SendMessage("Done."); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcast")] private void BroadcastCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { chan.SendMessage("You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "Broadcast: {0}", message); Log.WriteLine("Sphere", "Broadcast:{0}", message); if (message.Length < 70) { m_Server.WriteLine("b" + message); } else { message = message.Trim(); while (message.Length > 70) { m_Server.WriteLine("b " + message.Substring(0, 70)); message = message.Remove(0, 70); } m_Server.WriteLine("b " + message); } } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcastirc")] private void BroadcastIrcCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "IRC Broadcast: {0}", message); Log.WriteLine("Sphere", "IRC Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!go")] private void GoCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 2) { chan.SendMessage("Usage: !Go <uid> <message>"); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) { if (i != args[0]) message += " " + i; } m_Server.WriteLine("var.lothbot_target={0}", args[0]); m_Server.WriteLine("uid.{0}.respondtoplayer {1}", m_LothBotUid, message.Trim()); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("admin listlog")] private void AdminListLogCommand(NetworkUser user, string[] args) { string[] logFiles = Directory.GetFiles(m_Config.LogDirectory, "*.log"); if(logFiles.Length == 0) { user.SendMessage("There are no log files available."); } else { user.SendMessage("The following log files are available:"); foreach(string log in logFiles) user.SendMessage("\t{0}", log); } } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("addstaff")] private void AddStaffCommand(NetworkUser user, string[] args) { if (args.Length < 1) { user.SendMessage("You must at least provide an account name."); return; } else if (args.Length > 3) { user.SendMessage("Too many arguments provided! (AddStaff <Account> [<Priv>] [<Password>]"); return; } if (!m_Server.IsConnected) { user.SendMessage("Unable to add accounts whilst not connected to the server!"); return; } switch (args.Length) { case 1: { if (m_Accounting.AccountAdd(args[0], AccountPriv.Counselor)) user.SendMessage("Counselor account '{0}' created successfully! Password is '{1}'", args[0], "blah"); else user.SendMessage("Unable to create account!"); return; } case 2: { if (m_Accounting.AccountAdd(args[0], Account.StringToPriv(args[1]))) user.SendMessage("{1} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), "blah"); else user.SendMessage("Unable to create account!"); return; } case 3: { if (m_Accounting.AccountAdd(args[0], args[2], Account.StringToPriv(args[1]))) user.SendMessage("{2} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), args[2]); else user.SendMessage("Unable to create account!"); return; } } } #endregion #region Jail Commands [PrivateCommand("jail")] private void JailCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Jail <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Add <Account> <Length> [<Reason>]'"); return; } if (m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' is already jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.Jail(args[1], null, user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}' jailed for {1} hours!", args[1], args[2]); else user.SendNotice("Unable to jail '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Del <Account>'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } if (m_JailSystem.Release(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Edit <Account> <Length> [<Reason>]'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.EditJail(args[1], user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}'s jail entry is edited!", args[1]); else user.SendNotice("Unable to edit jail entry '{0}'!", args[1]); return; } case "list": { if (m_JailSystem.JailedAccounts <= 0) { user.SendNotice("No Accounts are Jailed!"); return; } foreach (JailEntry entry in m_JailSystem.GetJailEntryList()) { user.SendNotice("Account: {0} Release Date: {1}", entry.Account, entry.JailedUntil.ToString()); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Info <Account>'"); return; } JailEntry entry = m_JailSystem.GetJailEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Jailed By: {0}", entry.JailedBy); user.SendNotice("Jail Date: {0}", entry.JailedOn); user.SendNotice("Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Jailed!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_JailSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Add <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new jail database entry for <Account>. The account will"); user.SendNotice("automatically be jailed ingame."); user.SendNotice("The release date will be set <Length> hours after the jail"); user.SendNotice("time, and will automatically released from jail at that time."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Jail Add myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Add myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically released ingame."); user.SendNotice("Example: /msg {0} Jail Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Edit <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the"); user.SendNotice("entry's length to <Length> hours."); user.SendNotice("If [<Reason>] is provided then this will also be amended."); user.SendNotice("The 'Jailed By' property of the jail entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice("Example: /msg {0} Jail Edit myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Edit myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Jail Database to be saved immediately. Unsaved jail"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Jail Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Jail List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently jailed accounts, along with"); user.SendNotice("their release dates. For more information on a jail entry, use"); user.SendNotice("Jail Info"); user.SendNotice("Example: /msg {0} Jail List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Jail Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s jail entry."); user.SendNotice("Example: /msg {0} Jail Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } } } #endregion #region Ban Commands [PrivateCommand("ban")] private void BanCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Ban <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Add <Account> [<Reason>]'"); return; } if (m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' is already banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.Ban(args[1], null, user.Nickname, banargs.Trim())) user.SendNotice("'{0}' banned!", args[1]); else user.SendNotice("Unable to ban '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Del <Account>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } if (m_BanSystem.UnBan(args[1], user.Nickname)) user.SendNotice("'{0}' unbanned!", args[1]); else user.SendNotice("Unable to unban '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Ban Edit <Account> <Reason>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.EditBan(args[1], user.Nickname, banargs.Trim())) user.SendNotice("'{0}'s ban entry is edited!", args[1]); else user.SendNotice("Unable to edit ban entry '{0}'!", args[1]); return; } case "list": { if (m_BanSystem.BannedAccounts <= 0) { user.SendNotice("No Accounts are Banned!"); return; } foreach (BanEntry entry in m_BanSystem.GetBanEntryList()) { user.SendNotice("Account: {0}", entry.Account); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Info <Account>'"); return; } BanEntry entry = m_BanSystem.GetBanEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Banned By: {0}", entry.BannedBy); user.SendNotice("Ban Date: {0}", entry.BannedOn); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Banned!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_BanSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Add <Account> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new ban database entry for <Account>. The account will"); user.SendNotice("automatically be banned ingame."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Ban Add myAccount", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Ban Add myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically be unbanned ingame."); user.SendNotice("Example: /msg {0} Ban Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Edit <Account> <Reason>", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the."); user.SendNotice("current Reason to <Reason>."); user.SendNotice("The 'Banned By' property of the ban entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice(" /msg {0} Ban Edit myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Ban Database to be saved immediately. Unsaved ban"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Ban Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Ban List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently banned accounts, along with"); user.SendNotice("their release dates. For more information on a ban entry, use"); user.SendNotice("Ban Info"); user.SendNotice("Example: /msg {0} Ban List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Ban Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s ban entry."); user.SendNotice("Example: /msg {0} Ban Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } } } #endregion #region Page Commands [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!pages")] private void PagesCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages <= 0) { user.SendNotice("There are no pages to list!"); return; } user.SendNotice("Pages: {0}", pages); for (int i = 0; i < pages; i++) { user.SendNotice( "{0}. Time=\"{1} minutes ago\" Account=\"{2}\" Reason=\"{3}\"", (i + 1), (Int32.Parse((string)m_Server.GetProperty(String.Format("GMPAGE.{0}.TIME", i)), System.Globalization.NumberStyles.HexNumber) / 60), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.ACCOUNT", i)), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.REASON", i)) ); } } [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!page delete")] private void PageCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } if (args.Length <= 0) { PagesCommand(chan, user, args); return; } int page; try {page = Int32.Parse(args[0]) - 1; } catch { return; } if (page < 0) { chan.SendMessage("You must specify a page number greater than 0."); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages < page) { chan.SendMessage("This page doesn't exist!"); return; } m_Server.WriteLine("GMPAGE.{0}.DELETE", page); chan.SendMessage("Page deleted."); } #endregion #region Log Manager Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [PrivateCommand("log")] private void LogCommand(NetworkUser user, string[] args) { if (args.Length <= 1) { user.SendMessage("Usage: Log <command> <type> [<args>]"); return; } switch (args[0].ToLower()) { #region Log List case "list": { DateTime from = DateTime.Parse("01/01/1900"); DateTime to = DateTime.Parse("01/01/3000"); Type logtype; try ! { if (args.Length >= 3) from = DateTime.Parse(args[2]); if (args.Length >= 4) to = DateTime.Parse(args[3]); } catch { user.SendMessage("Invalid Date/Time(s)."); return; } switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); foreach (LogEntry entry in m_LogManager.GetEntriesBetweenTimes(from, to)) { if (entry.Type == logtype) entries.Add( entry ); /*else { Console.WriteLine(); Console.WriteLine("MESSAGE: {0}", entry.RawString); Console.WriteLine("TYPE: {0}", entry.Type.FullName); }*/ } if (entries.Count <= 0) { user.SendMessage("No log messages found."); return; } for (int i = 0; i < entries.Count; i++) { user.SendMessage("{0}. {1}", (i + 1), m_LogManager.CreateMessage( (LogEntry)entries[i] )); } return; } #endregion #region Log Handle case "handle": { if (args.Length < 3) { user.SendMessage("Usage: Log Handle <type> <lognumber>"); return; } Type logtype; switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break... [truncated message content] |
From: Mr S. C. <mrs...@us...> - 2005-02-17 02:29:38
|
Update of /cvsroot/bobbot/Plugins/Sphere/PunishSystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31600/Sphere/PunishSystem Modified Files: JailSystem.cs Log Message: Added a check to ensure an Account was retrieved when attempt to jail one. !stats now shows the correct number of pages. LogManager won't store duplicate housekill messages. (Work being done on scripts to reduce the overall amount of these being produced) Index: JailSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/PunishSystem/JailSystem.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JailSystem.cs 15 Feb 2005 21:47:28 -0000 1.2 --- JailSystem.cs 17 Feb 2005 02:29:28 -0000 1.3 *************** *** 294,297 **** --- 294,304 ---- Account jailed = AccountRegistration.Instance.GetAccount(account); + + if (jailed == null) + { + Log.WriteLine("Sphere (JailDB)", "Account '{0}' doesn't exist and cannot be jailed!", account); + return false; + } + for (int i = 0; i < jailed.Chars; i++) { *************** *** 306,310 **** } ! catch { return false; } } --- 313,321 ---- } ! catch (Exception e) ! { ! Console.WriteLine(e.ToString()); ! return false; ! } } *************** *** 406,410 **** string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! if (!Jail(account, character, gm, args.Message.Length.ToString(), args.Message.Reason)) Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Jail Account '{0}'.", account); } --- 417,421 ---- string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! if (!Jail(account, character, gm, args.Message.Length, args.Message.Reason)) Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Jail Account '{0}'.", account); } |
From: Mr S. C. <mrs...@us...> - 2005-02-17 02:29:37
|
Update of /cvsroot/bobbot/Plugins/Sphere/LogManagement In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31600/Sphere/LogManagement Modified Files: LogManager.cs Log Message: Added a check to ensure an Account was retrieved when attempt to jail one. !stats now shows the correct number of pages. LogManager won't store duplicate housekill messages. (Work being done on scripts to reduce the overall amount of these being produced) Index: LogManager.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/LogManagement/LogManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LogManager.cs 15 Feb 2005 21:47:30 -0000 1.1 --- LogManager.cs 17 Feb 2005 02:29:28 -0000 1.2 *************** *** 132,135 **** --- 132,138 ---- private void OnHouseKilling(object sender, HouseKillingEventArgs args) { + if (RawMessageFound(m_LastMessage, args.Message.Time)) + return; + m_LogEntries.Add(new LogEntry(args.Message, m_LastMessage)); } *************** *** 258,261 **** --- 261,275 ---- } + public bool RawMessageFound(string message, DateTime date) + { + foreach (LogEntry entry in m_LogEntries) + { + if (entry.RawString.ToLower() == message.ToLower() && date == entry.Time) + return true; + } + + return false; + } + #endregion } |
From: Mr S. C. <mrs...@us...> - 2005-02-17 02:25:18
|
Update of /cvsroot/bobbot/Other/SphereConnection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30524/SphereConnection Modified Files: SphereConnection.cs Types.cs Log Message: Position struct can now Parse x,y co-ordinates (Position).ToString() will now return different co-ordinate formats based on the Position it represents (x,y; x,y,z; x,y,z,m) Index: Types.cs =================================================================== RCS file: /cvsroot/bobbot/Other/SphereConnection/Types.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Types.cs 4 Jan 2005 23:15:58 -0000 1.1 --- Types.cs 17 Feb 2005 02:25:10 -0000 1.2 *************** *** 80,84 **** Position pos = new Position(); ! if(parts.Length == 3) { try --- 80,84 ---- Position pos = new Position(); ! if (parts.Length == 4) { try *************** *** 87,90 **** --- 87,91 ---- pos.Y = Int32.Parse(parts[1]); pos.Z = Int32.Parse(parts[2]); + pos.Plane = Int32.Parse(parts[3]); } catch *************** *** 92,96 **** } } ! else if(parts.Length == 4) { try --- 93,97 ---- } } ! else if (parts.Length == 3) { try *************** *** 99,103 **** pos.Y = Int32.Parse(parts[1]); pos.Z = Int32.Parse(parts[2]); ! pos.Plane = Int32.Parse(parts[3]); } catch --- 100,114 ---- pos.Y = Int32.Parse(parts[1]); pos.Z = Int32.Parse(parts[2]); ! } ! catch ! { ! } ! } ! else if (parts.Length == 2) ! { ! try ! { ! pos.X = Int32.Parse(parts[0]); ! pos.Y = Int32.Parse(parts[1]); } catch *************** *** 115,119 **** public override string ToString() { ! return String.Format("{0},{1},{2},{3}", X, Y, Z, Plane); } } --- 126,136 ---- public override string ToString() { ! if (Plane != 0) ! return String.Format("{0},{1},{2},{3}", X, Y, Z, Plane); ! else if (Z != 0) ! return String.Format("{0},{1},{2}", X, Y, Z); ! else ! return String.Format("{0},{1}", X, Y); ! //return String.Format("{0},{1},{2},{3}", X, Y, Z, Plane); } } Index: SphereConnection.cs =================================================================== RCS file: /cvsroot/bobbot/Other/SphereConnection/SphereConnection.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SphereConnection.cs 15 Feb 2005 23:50:23 -0000 1.5 --- SphereConnection.cs 17 Feb 2005 02:25:10 -0000 1.6 *************** *** 461,466 **** m_AccountQueryTempValue = Convert.ChangeType(j.Value, account.Type); } ! catch(FormatException) { m_AccountQueryTempValue = null; } --- 461,467 ---- m_AccountQueryTempValue = Convert.ChangeType(j.Value, account.Type); } ! catch(FormatException e) { + Console.WriteLine(e.ToString()); m_AccountQueryTempValue = null; } *************** *** 484,487 **** --- 485,490 ---- msg.Parse(args.Message); + Console.WriteLine("Object={0} Property={1} Value={2}", msg.Object, msg.Property, msg.Value); + if((msg.Value != null) && (msg.Property != null)) { |
From: Mr S. C. <mrs...@us...> - 2005-02-15 23:53:08
|
Update of /cvsroot/bobbot/Plugins/Sphere In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28210/Sphere Modified Files: SpherePlugin.cs Log Message: - Nothing much here, in fact I don't think there's anything changed at all, but apparently this CVS thingy says there is :) Index: SpherePlugin.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/SpherePlugin.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SpherePlugin.cs 15 Feb 2005 21:47:28 -0000 1.16 --- SpherePlugin.cs 15 Feb 2005 23:52:45 -0000 1.17 *************** *** 1,3 **** ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Plugins.Sphere.LogManagement; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private LogManager m_LogManager; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_Server.ClientConnected += new ClientConnectedEventHandler(OnClientConnected); Bot.Core.Kernel.Instance.Network.Welcome += new WelcomeReplyEventHandler(OnNetworkWelcome); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); m_LogManager = new LogManager(m_Server, m_Config.LogDatabase); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); //Log.WriteLine("Sphere", args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem.SaveDatabase(); m_BanSystem.SaveDatabase(); m_LogManager.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } private void OnClientConnected(object sender, ClientConnectedEventArgs args) --- 1,3 ---- ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Plugins.Sphere.LogManagement; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private LogManager m_LogManager; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_Server.ClientConnected += new ClientConnectedEventHandler(OnClientConnected); m_Server.RegisterHandler(typeof(HouseKillingMessage)); m_Server.RegisterHandler(typeof(PlayerJailedMessage)); m_Server.RegisterHandler(typeof(PlayerReleasedMessage)); m_Server.RegisterHandler(typeof(SkillNukeMessage)); Bot.Core.Kernel.Instance.Network.Welcome += new WelcomeReplyEventHandler(OnNetworkWelcome); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); m_LogManager = new LogManager(m_Server, m_Config.LogDatabase); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); //Log.WriteLine("Sphere", args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem.SaveDatabase(); m_BanSystem.SaveDatabase(); m_LogManager.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } private void OnClientConnected(object sender, ClientConnectedEventArgs args) *************** *** 6,146 **** m_ClientPeak = args.Message.ClientCount; } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Password: {1}", temp.Name, temp.Password); Kernel.Instance.Network.SendPrivateMessage(user, "Lang: {0} PLevel: {1}", temp.Lang, Account.PrivToString(temp.Plevel)); Kernel.Instance.Network.SendPrivateMessage(user, "FirstIP: {0} FirstDate: {1}", temp.FirstIP, temp.FirstConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "LastIP: {0} LastDate: {1}", temp.LastIP, temp.LastConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "Chars: {0} LastChar: 0{1:x}", temp.Chars, temp.LastCharUID); Kernel.Instance.Network.SendPrivateMessage(user, "TotalConnect: {0} LastConnect: {1}", temp.TotalConnectTime, temp.LastConnectTime); Kernel.Instance.Network.SendPrivateMessage(user, "Priv: 0{0:x}", temp.Priv); Kernel.Instance.Network.SendPrivateMessage(user, "Jailed: {0} Blocked: {1}", ((temp.Jailed)? "Yes" : "No"), ((temp.Blocked)? "Yes" : "No")); } return; } } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testitem")] private void testitemcommand(NetworkUser user, string[] args) { if (args.Length != 2) return; user.SendMessage("Value '{0}' for '{1}' is {2}", args[1], args[0], m_Server.GetItemProperty(Int32.Parse(args[0], System.Globalization.NumberStyles.HexNumber), args[1])); } [PrivateCommand("mypriv")] private void myprivcommand(NetworkUser user, string[] args) { user.SendNotice("Your priv is: {0}", Account.PrivToString(m_SphereAuth.GetStaffPriv(user))); return; } [PrivateCommand("liststaff")] private void liststaffcommand(NetworkUser user, string[] args) { foreach (Bot.Core.User staff in m_SphereAuth.StaffMembers()) user.SendNotice("{0}, {1}", staff.Name, Account.PrivToString((AccountPriv)staff.GetProperty("LothStaff"))); } [ChannelCommand("listchan")] private void ListChan(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "I am on the following channels:"); foreach(string channel in Kernel.Instance.Network.Channels.Keys) Kernel.Instance.Network.SendChannelMessage(chan, "\t\t{0}", channel); } #endregion #region 'Remote' Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [RemoteCommand("account")] private static void RemoteAccountCommand(RemoteConnection sender, string[] args) { if (args.Length < 2) { sender.Send("Invalid Command or Format."); return; } if (args[0].ToLower() == "add") switch (args.Length) { case 2: { if (AccountRegistration.Instance.AccountAdd(args[1])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } case 3: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } default: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2], Account.StringToPriv(args[3]))) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } } else if (args[1].ToLower() == "delete") { if (AccountRegistration.Instance.AccountDel(args[0])) sender.Send("Account {0} deleted!", args[0]); ! else sender.Send("Unable to delete account!"); return; } else { string[] function = new string[ args.Length - 1 ]; Array.Copy(args, 1, function, 0, function.Length); sender.Send(AccountRegistration.Instance.AccountMod(args[0], function)); } } #endregion #region 'Staff' Commands #region Connection Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!recon", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void ReconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); if (args.Length <= 0) m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); else m_Server.Connect(IPAddress.Parse(args[0]), m_Config.Port); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!discon", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void DisconCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (m_Server.IsConnected) m_Server.Disconnect(); else chan.SendMessage("Not Connected To Server."); } #endregion #region Misc Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!resync")] private void ResyncCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } m_Server.WriteLine("r"); m_Server.WriteLine("r"); chan.SendMessage("Done."); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcast")] private void BroadcastCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { chan.SendMessage("You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "Broadcast: {0}", message); Log.WriteLine("Sphere", "Broadcast:{0}", message); if (message.Length < 70) { m_Server.WriteLine("b" + message); } else { message = message.Trim(); while (message.Length > 70) { m_Server.WriteLine("b " + message.Substring(0, 70)); message = message.Remove(0, 70); } m_Server.WriteLine("b " + message); } } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!broadcastirc", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void BroadcastIrcCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "IRC Broadcast: {0}", message); Log.WriteLine("Sphere", "IRC Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!go", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void GoCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (args.Length < 2) { chan.SendMessage("Usage: !Go <uid> <message>"); return; } if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } string message = ""; foreach (string i in args) { if (i != args[0]) message += " " + i; } m_Server.WriteLine("var.lothbot_target={0}", args[0]); m_Server.WriteLine("uid.{0}.respondtoplayer {1}", m_LothBotUid, message.Trim()); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("admin listlog")] private void AdminListLogCommand(NetworkUser user, string[] args) { string[] logFiles = Directory.GetFiles(m_Config.LogDirectory, "*.log"); if(logFiles.Length == 0) { user.SendMessage("There are no log files available."); } else { user.SendMessage("The following log files are available:"); foreach(string log in logFiles) user.SendMessage("\t{0}", log); } } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("addstaff")] private void AddStaffCommand(NetworkUser user, string[] args) { if (args.Length < 1) { user.SendMessage("You must at least provide an account name."); return; } else if (args.Length > 3) { user.SendMessage("Too many arguments provided! (AddStaff <Account> [<Priv>] [<Password>]"); return; } if (!m_Server.IsConnected) { user.SendMessage("Unable to add accounts whilst not connected to the server!"); return; } switch (args.Length) { case 1: { if (m_Accounting.AccountAdd(args[0], AccountPriv.Counselor)) user.SendMessage("Counselor account '{0}' created successfully! Password is '{1}'", args[0], "blah"); else user.SendMessage("Unable to create account!"); return; } case 2: { if (m_Accounting.AccountAdd(args[0], Account.StringToPriv(args[1]))) user.SendMessage("{1} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), "blah"); else user.SendMessage("Unable to create account!"); return; } case 3: { if (m_Accounting.AccountAdd(args[0], args[2], Account.StringToPriv(args[1]))) user.SendMessage("{2} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), args[2]); else user.SendMessage("Unable to create account!"); return; } } } #endregion #region Jail Commands [PrivateCommand("jail")] private void JailCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Jail <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Add <Account> <Length> [<Reason>]'"); return; } if (m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' is already jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.Jail(args[1], null, user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}' jailed for {1} hours!", args[1], args[2]); else user.SendNotice("Unable to jail '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Del <Account>'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } if (m_JailSystem.Release(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Edit <Account> <Length> [<Reason>]'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.EditJail(args[1], user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}'s jail entry is edited!", args[1]); else user.SendNotice("Unable to edit jail entry '{0}'!", args[1]); return; } case "list": { if (m_JailSystem.JailedAccounts <= 0) { user.SendNotice("No Accounts are Jailed!"); return; } foreach (JailEntry entry in m_JailSystem.GetJailEntryList()) { user.SendNotice("Account: {0} Release Date: {1}", entry.Account, entry.JailedUntil.ToString()); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Info <Account>'"); return; } JailEntry entry = m_JailSystem.GetJailEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Jailed By: {0}", entry.JailedBy); user.SendNotice("Jail Date: {0}", entry.JailedOn); user.SendNotice("Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Jailed!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_JailSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Add <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new jail database entry for <Account>. The account will"); user.SendNotice("automatically be jailed ingame."); user.SendNotice("The release date will be set <Length> hours after the jail"); user.SendNotice("time, and will automatically released from jail at that time."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Jail Add myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Add myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically released ingame."); user.SendNotice("Example: /msg {0} Jail Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Edit <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the"); user.SendNotice("entry's length to <Length> hours."); user.SendNotice("If [<Reason>] is provided then this will also be amended."); user.SendNotice("The 'Jailed By' property of the jail entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice("Example: /msg {0} Jail Edit myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Edit myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Jail Database to be saved immediately. Unsaved jail"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Jail Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Jail List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently jailed accounts, along with"); user.SendNotice("their release dates. For more information on a jail entry, use"); user.SendNotice("Jail Info"); user.SendNotice("Example: /msg {0} Jail List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Jail Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s jail entry."); user.SendNotice("Example: /msg {0} Jail Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } } } #endregion #region Ban Commands [PrivateCommand("ban")] private void BanCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Ban <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Add <Account> [<Reason>]'"); return; } if (m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' is already banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.Ban(args[1], null, user.Nickname, banargs.Trim())) user.SendNotice("'{0}' banned!", args[1]); else user.SendNotice("Unable to ban '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Del <Account>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } if (m_BanSystem.UnBan(args[1], user.Nickname)) user.SendNotice("'{0}' unbanned!", args[1]); else user.SendNotice("Unable to unban '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Ban Edit <Account> <Reason>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.EditBan(args[1], user.Nickname, banargs.Trim())) user.SendNotice("'{0}'s ban entry is edited!", args[1]); else user.SendNotice("Unable to edit ban entry '{0}'!", args[1]); return; } case "list": { if (m_BanSystem.BannedAccounts <= 0) { user.SendNotice("No Accounts are Banned!"); return; } foreach (BanEntry entry in m_BanSystem.GetBanEntryList()) { user.SendNotice("Account: {0}", entry.Account); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Info <Account>'"); return; } BanEntry entry = m_BanSystem.GetBanEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Banned By: {0}", entry.BannedBy); user.SendNotice("Ban Date: {0}", entry.BannedOn); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Banned!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_BanSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Add <Account> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new ban database entry for <Account>. The account will"); user.SendNotice("automatically be banned ingame."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Ban Add myAccount", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Ban Add myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically be unbanned ingame."); user.SendNotice("Example: /msg {0} Ban Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Edit <Account> <Reason>", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the."); user.SendNotice("current Reason to <Reason>."); user.SendNotice("The 'Banned By' property of the ban entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice(" /msg {0} Ban Edit myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Ban Database to be saved immediately. Unsaved ban"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Ban Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Ban List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently banned accounts, along with"); user.SendNotice("their release dates. For more information on a ban entry, use"); user.SendNotice("Ban Info"); user.SendNotice("Example: /msg {0} Ban List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Ban Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s ban entry."); user.SendNotice("Example: /msg {0} Ban Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } } } #endregion #region Page Commands [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!pages")] private void PagesCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages <= 0) { user.SendNotice("There are no pages to list!"); return; } user.SendNotice("Pages: {0}", pages); for (int i = 0; i < pages; i++) { user.SendNotice( "{0}. Time=\"{1} minutes ago\" Account=\"{2}\" Reason=\"{3}\"", (i + 1), (Int32.Parse((string)m_Server.GetProperty(String.Format("GMPAGE.{0}.TIME", i)), System.Globalization.NumberStyles.HexNumber) / 60), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.ACCOUNT", i)), (string)m_Server.GetProperty(String.Format("GMPAGE.{0}.REASON", i)) ); } } [AllowCondition("LothStaff", AccountPriv.Counselor, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [AllowCondition("StaffChannel", true, AllowConditionUsage.Equals, AllowConditionTarget.Channel)] [ChannelCommand("!page delete")] private void PageCommand(NetworkChannel chan, NetworkUser user, string[] args) { if (!m_Server.IsConnected) { chan.SendMessage("Not Connected To Server"); return; } if (args.Length <= 0) { PagesCommand(chan, user, args); return; } int page; try {page = Int32.Parse(args[0]) - 1; } catch { return; } if (page < 0) { chan.SendMessage("You must specify a page number greater than 0."); return; } int pages = (int)m_Server.GetProperty("GMPAGES", typeof(int)); if (pages < page) { chan.SendMessage("This page doesn't exist!"); return; } m_Server.WriteLine("GMPAGE.{0}.DELETE", page); chan.SendMessage("Page deleted."); } #endregion #region Log Manager Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [PrivateCommand("log")] private void LogCommand(NetworkUser user, string[] args) { if (args.Length <= 1) { user.SendMessage("Usage: Log <command> <type> [<args>]"); return; } switch (args[0].ToLower()) { #region Log List case "list": { DateTime from = DateTime.Parse("01/01/1900"); DateTime to = DateTime.Parse("01/01/3000"); Type logtype; try ! { if (args.Length >= 3) from = DateTime.Parse(args[2]); if (args.Length >= 4) to = DateTime.Parse(args[3]); } catch { user.SendMessage("Invalid Date/Time(s)."); return; } switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); foreach (LogEntry entry in m_LogManager.GetEntriesBetweenTimes(from, to)) { if (entry.Type == logtype) entries.Add( entry ); } if (entries.Count <= 0) { user.SendMessage("No log messages found."); return; } for (int i = 0; i < entries.Count; i++) { user.SendMessage("{0}. {1}", (i + 1), m_LogManager.CreateMessage( (LogEntry)entries[i] )); } return; } #endregion #region Log Handle case "handle": { if (args.Length < 3) { user.SendMessage("Usage: Log Handle <type> <lognumber>"); return; } Type logtype; switch (args[1].ToLower()) { case "page": { logtype = typeof(ClientPageMessage); break; } case "housekill": { logtype = typeof(HouseKillingMessage); break; } case "ride": { logtype = typeof(RideLostMessage); break; } case "skill": { logtype = typeof(SkillNukeMessage); break; } default: { user.SendMessage("Unknown log message type. Try 'page', 'housekill', 'skill', or 'ride'"); return; } } ArrayList entries = new ArrayList(); ... [truncated message content] |
From: Mr S. C. <mrs...@us...> - 2005-02-15 23:50:44
|
Update of /cvsroot/bobbot/Other/SphereConnection/Messages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27648/SphereConnection/Messages Added Files: ClientKICKedMessage.cs RideLostMessage.cs Log Message: - Added ClientKICKed and RideLost Messages & Events - Moved ScriptErrorMessage event handling to prevent custom messages registered afterwards from being ignored. --- NEW FILE: RideLostMessage.cs --- #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Net; using System.Text.RegularExpressions; namespace Bot.Other.Sphere.Messages { public delegate void RideLostEventHandler(object sender, RideLostEventArgs args); /// <summary> /// Summary description for RideLostMessage. /// </summary> public class RideLostMessage : BaseMessage { #region Members protected Regex m_Regex = new Regex( @"^([0-9]{2}:[0-9]{2}):ERROR:RIDDEN NPC NOT ACTING AS SUCH: UID=(.+), id=(.+) '(.+)', Invalid code=(.+)", RegexOptions.Compiled ); protected DateTime m_Time; protected int m_Serial; protected int m_Id; protected string m_Name; protected int m_Code; #endregion #region Public properties /// <summary> /// The time this message was sent. /// </summary> public DateTime Time { get { return m_Time; } } /// <summary> /// Ride serial number. /// </summary> public int Serial { get { return m_Serial; } } /// <summary> /// Ride ID /// </summary> public int ID { get { return m_Id; } } /// <summary> /// Ride Name. /// </summary> public string Name { get { return m_Name; } } /// <summary> /// Error code. /// </summary> public int Code { get { return m_Code; } } #endregion public RideLostMessage() { } public override bool CanParse(string message) { if(m_Regex.IsMatch(message)) return true; return false; } public override void Parse(string message) { if(!CanParse(message)) throw new MessageParserException("Cannot parse this message.", message); Match match = m_Regex.Match(message); if(!match.Success) return; m_Time = DateTime.Parse(match.Groups[1].Value); m_Serial = Int32.Parse(match.Groups[2].Value, System.Globalization.NumberStyles.HexNumber); m_Id = Int32.Parse(match.Groups[3].Value, System.Globalization.NumberStyles.HexNumber); m_Name = match.Groups[4].Value; m_Code = Int32.Parse(match.Groups[5].Value); } public override void Notify(SphereConnection server) { server.OnRideLost(new RideLostEventArgs(this)); } } public class RideLostEventArgs : System.EventArgs { protected RideLostMessage m_Message; /// <summary> /// Gets the <see cref="Plugin.Messages.RideLostMessage"/> object of this event. /// </summary> public RideLostMessage Message { get { return m_Message; } } /// <summary> /// Instanciates the <see cref="RideLostEventArgs"/> class with a <see cref="RideLostMessage"/> object. /// </summary> /// <param name="msg"></param> public RideLostEventArgs(RideLostMessage msg) { m_Message = msg; } } } --- NEW FILE: ClientKICKedMessage.cs --- #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Net; using System.Text.RegularExpressions; namespace Bot.Other.Sphere.Messages { public delegate void ClientKICKedEventHandler(object sender, ClientKICKedEventArgs args); /// <summary> /// Summary description for ClientKICKedMessage. /// </summary> [Serializable] public class ClientKICKedMessage : BaseMessage { #region Members //17:48:A'Koveras' was KICKed by 'Admin Sully' protected Regex m_Regex = new Regex( @"^([0-9]{2}:[0-9]{2}):A'(.+) was KICKed by '(.+)'", RegexOptions.Compiled ); protected Regex m_Regex2 = new Regex( @"^([0-9]{2}:[0-9]{2}):\((.+)\)A'(.+)' was KICKed by '(.+)'", RegexOptions.Compiled ); protected DateTime m_Time; protected string m_Account; protected string m_Staff; #endregion #region Public properties /// <summary> /// The time this message was sent. /// </summary> public DateTime Time { get { return m_Time; } } /// <summary> /// The banned client's Account /// </summary> public string Account { get { return m_Account; } } /// <summary> /// The source of the Ban. /// </summary> public string Staff { get { return m_Staff; } } #endregion public ClientKICKedMessage() { } public override bool CanParse(string message) { if(m_Regex.IsMatch(message)) return true; else if (m_Regex2.IsMatch(message)) return true; return false; } public override void Parse(string message) { if(!CanParse(message)) throw new MessageParserException("Cannot parse this message.", message); Match match = m_Regex.Match(message); if(match.Success) { m_Time = DateTime.Parse(match.Groups[1].Value); m_Account = match.Groups[2].Value; m_Staff = match.Groups[3].Value; } else { match = m_Regex2.Match(message); if (!match.Success) return; m_Time = DateTime.Parse(match.Groups[1].Value); m_Account = match.Groups[3].Value; m_Staff = match.Groups[4].Value; } } public override void Notify(SphereConnection server) { server.OnClientKICKed(new ClientKICKedEventArgs(this)); } } [Serializable] public class ClientKICKedEventArgs : System.EventArgs { protected ClientKICKedMessage m_Message; /// <summary> /// Gets the <see cref="Plugin.Messages.ClientKICKedMessage"/> object of this event. /// </summary> public ClientKICKedMessage Message { get { return m_Message; } } /// <summary> /// Instanciates the <see cref="ClientKICKedEventArgs"/> class with a <see cref="ClientKICKedMessage"/> object. /// </summary> /// <param name="msg"></param> public ClientKICKedEventArgs(ClientKICKedMessage msg) { m_Message = msg; } } } |
From: Mr S. C. <mrs...@us...> - 2005-02-15 23:50:43
|
Update of /cvsroot/bobbot/Other/SphereConnection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27648/SphereConnection Modified Files: SphereConnection.cs Log Message: - Added ClientKICKed and RideLost Messages & Events - Moved ScriptErrorMessage event handling to prevent custom messages registered afterwards from being ignored. Index: SphereConnection.cs =================================================================== RCS file: /cvsroot/bobbot/Other/SphereConnection/SphereConnection.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SphereConnection.cs 15 Feb 2005 23:20:37 -0000 1.4 --- SphereConnection.cs 15 Feb 2005 23:50:23 -0000 1.5 *************** *** 142,145 **** --- 142,147 ---- public event UnknownCommandEventHandler UnknownCommand; public event AccountDoesNotExistEventHandler AccountDoesNotExist; + public event RideLostEventHandler RideLost; + public event ClientKICKedEventHandler ClientKICKed; #endregion *************** *** 157,161 **** m_MessageParsers.Add(typeof(ClientPageMessage)); m_MessageParsers.Add(typeof(ServerInfoMessage)); ! m_MessageParsers.Add(typeof(ScriptErrorMessage)); m_MessageParsers.Add(typeof(ClientLoginMessage)); m_MessageParsers.Add(typeof(HttpRequestMessage)); --- 159,163 ---- m_MessageParsers.Add(typeof(ClientPageMessage)); m_MessageParsers.Add(typeof(ServerInfoMessage)); ! //m_MessageParsers.Add(typeof(ScriptErrorMessage)); m_MessageParsers.Add(typeof(ClientLoginMessage)); m_MessageParsers.Add(typeof(HttpRequestMessage)); *************** *** 178,181 **** --- 180,185 ---- m_MessageParsers.Add(typeof(AccountDoesNotExistMessage)); m_MessageParsers.Add(typeof(ClientCharacterSelectedMessage)); + m_MessageParsers.Add(typeof(RideLostMessage)); + m_MessageParsers.Add(typeof(ClientKICKedMessage)); m_QueryBuffer = new ArrayList(); *************** *** 565,575 **** if(msg == null) { ! // Try to see if its a custom log message. ! msg = new CustomLogMessage(); ! if(msg.CanParse(args.Message)) { msg.Parse(args.Message); ! } else { ! return; } } --- 569,593 ---- if(msg == null) { ! // Try to see if its a script error message. ! msg = new ScriptErrorMessage(); ! if (msg.CanParse(args.Message)) ! { msg.Parse(args.Message); ! } ! ! else ! { ! // Try to see if its a custom log message. ! msg = new CustomLogMessage(); ! ! if(msg.CanParse(args.Message)) ! { ! msg.Parse(args.Message); ! } ! else ! { ! return; ! } } } *************** *** 757,760 **** --- 775,790 ---- } + internal void OnRideLost(RideLostEventArgs args) + { + if (RideLost != null) + RideLost(this, args); + } + + internal void OnClientKICKed(ClientKICKedEventArgs args) + { + if (ClientKICKed != null) + ClientKICKed(this, args); + } + public void OnCustomEvent(EventArgs args) { |
From: Iain M. <iai...@us...> - 2005-02-15 23:20:46
|
Update of /cvsroot/bobbot/Other/SphereConnection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21077/SphereConnection Modified Files: SphereConnection.cs Log Message: CustomLogMessage removed from standard queue, now explicility checked after all other handlers. Index: SphereConnection.cs =================================================================== RCS file: /cvsroot/bobbot/Other/SphereConnection/SphereConnection.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SphereConnection.cs 7 Feb 2005 02:26:57 -0000 1.3 --- SphereConnection.cs 15 Feb 2005 23:20:37 -0000 1.4 *************** *** 154,158 **** m_MessageParsers.Add(typeof(WorldSaveMessage)); m_MessageParsers.Add(typeof(ShowValueMessage)); ! m_MessageParsers.Add(typeof(CustomLogMessage)); m_MessageParsers.Add(typeof(ClientPageMessage)); m_MessageParsers.Add(typeof(ServerInfoMessage)); --- 154,158 ---- m_MessageParsers.Add(typeof(WorldSaveMessage)); m_MessageParsers.Add(typeof(ShowValueMessage)); ! //m_MessageParsers.Add(typeof(CustomLogMessage)); m_MessageParsers.Add(typeof(ClientPageMessage)); m_MessageParsers.Add(typeof(ServerInfoMessage)); *************** *** 564,569 **** if(msg == null) ! return; msg.Notify(this); --- 564,577 ---- if(msg == null) ! { ! // Try to see if its a custom log message. ! msg = new CustomLogMessage(); + if(msg.CanParse(args.Message)) { + msg.Parse(args.Message); + } else { + return; + } + } msg.Notify(this); |
From: Mr S. C. <mrs...@us...> - 2005-02-15 21:53:19
|
Update of /cvsroot/bobbot/Plugins/Sphere/Messages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31010/Sphere/Messages Added Files: HouseKillingMessage.cs SkillNukeMessage.cs Log Message: - Added HouseKillingMessage and SkillNukeMessage --- NEW FILE: SkillNukeMessage.cs --- #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Net; using System.Globalization; using System.Text.RegularExpressions; using Bot.Plugins.Sphere; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere.Messages { public delegate void SkillNukeEventHandler(object sender, SkillNukeEventArgs args); /// <summary> /// Summary description for SkillNukeMessage. /// </summary> public class SkillNukeMessage : BaseMessage { #region Members protected Regex m_Regex = new Regex( @"^([0-9]{2}:[0-9]{2}):ERROR:\((.+)\)'(.+)' \((.+)\) nukes their (.+) skill from (.+)", RegexOptions.Compiled ); protected DateTime m_Time; protected string m_Script; protected string m_Name; protected string m_Account; protected string m_SkillName; protected string m_SkillBefore; #endregion #region Public properties /// <summary> /// The time this message was sent. /// </summary> public DateTime Time { get { return m_Time; } } public string Script { get { return m_Script; } } public string Name { get { return m_Name; } } public string Account { get { return m_Account; } } public string SkillName { get { return m_SkillName; } } public string SkillBefore { get { return m_SkillBefore; } } #endregion public SkillNukeMessage() { } public override bool CanParse(string message) { if(m_Regex.IsMatch(message)) return true; return false; } public override void Parse(string message) { if(!CanParse(message)) throw new MessageParserException("Cannot parse this message.", message); Match match = m_Regex.Match(message); if(!match.Success) return; m_Time = DateTime.Parse(match.Groups[1].Value); m_Script = match.Groups[2].Value; m_Name = match.Groups[3].Value; m_Account = match.Groups[4].Value; m_SkillName = match.Groups[5].Value; m_SkillBefore = match.Groups[6].Value; } public override void Notify(SphereConnection server) { server.OnCustomEvent(new SkillNukeEventArgs(this)); } } public class SkillNukeEventArgs : System.EventArgs { protected SkillNukeMessage m_Message; /// <summary> /// Gets the <see cref="Plugin.Messages.SkillNukeMessage"/> object of this event. /// </summary> public SkillNukeMessage Message { get { return m_Message; } } /// <summary> /// Instanciates the <see cref="SkillNukeEventArgs"/> class with a <see cref="SkillNukeMessage"/> object. /// </summary> /// <param name="msg"></param> public SkillNukeEventArgs(SkillNukeMessage msg) { m_Message = msg; } } } --- NEW FILE: HouseKillingMessage.cs --- #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.Net; using System.Globalization; using System.Text.RegularExpressions; using Bot.Plugins.Sphere; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere.Messages { public delegate void HouseKillingEventHandler(object sender, HouseKillingEventArgs args); /// <summary> /// Summary description for HouseKillingMessage. /// </summary> public class HouseKillingMessage : BaseMessage { #region Members protected Regex m_Regex = new Regex( @"^([0-9]{2}:[0-9]{2}):ERROR:\((.+)\)(.+) house killing\? \(Victim=(.+) Uid=(.+) P=(.+) \((.+)\), Aggressor=(.+) Uid=(.+) P=(.+) \((.+)\)\)", RegexOptions.Compiled ); protected DateTime m_Time; protected string m_Script; protected string m_VictimName; protected string m_VictimUid; protected string m_VictimP; protected string m_AggressorName; protected string m_AggressorUid; protected string m_AggresorP; #endregion #region Public properties /// <summary> /// The time this message was sent. /// </summary> public DateTime Time { get { return m_Time; } } public string Script { get { return m_Script; } } public string VictimName { get { return m_VictimName; } } public string VictimUid { get { return m_VictimName; } } public string VictimP { get { return m_VictimName; } } public string AggressorName { get { return m_AggressorName; } } public string AggressorUid { get { return m_AggressorName; } } public string AggressorP { get { return m_AggressorName; } } #endregion public HouseKillingMessage() { } public override bool CanParse(string message) { if(m_Regex.IsMatch(message)) return true; return false; } public override void Parse(string message) { if(!CanParse(message)) throw new MessageParserException("Cannot parse this message.", message); Match match = m_Regex.Match(message); if(!match.Success) return; m_Time = DateTime.Parse(match.Groups[1].Value); m_Script = match.Groups[2].Value; m_VictimName = match.Groups[4].Value; m_VictimUid = match.Groups[5].Value; m_VictimP = String.Format("{0} ({1})", match.Groups[6].Value, match.Groups[7].Value); m_AggressorName = match.Groups[8].Value; m_AggressorUid = match.Groups[9].Value; m_AggresorP = String.Format("{0} ({1})", match.Groups[10].Value, match.Groups[11].Value); } public override void Notify(SphereConnection server) { server.OnCustomEvent(new HouseKillingEventArgs(this)); } } public class HouseKillingEventArgs : System.EventArgs { protected HouseKillingMessage m_Message; /// <summary> /// Gets the <see cref="Plugin.Messages.HouseKillingMessage"/> object of this event. /// </summary> public HouseKillingMessage Message { get { return m_Message; } } /// <summary> /// Instanciates the <see cref="HouseKillingEventArgs"/> class with a <see cref="HouseKillingMessage"/> object. /// </summary> /// <param name="msg"></param> public HouseKillingEventArgs(HouseKillingMessage msg) { m_Message = msg; } } } |
From: Mr S. C. <mrs...@us...> - 2005-02-15 21:48:10
|
Update of /cvsroot/bobbot/Plugins/Sphere/PunishSystem In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/Sphere/PunishSystem Modified Files: BanSystem.cs JailSystem.cs Log Message: - Ban System now registers bans made through scripts & .kick command. - Added <LogDatabase></LogDatabase> to the config. (should be added to bob.exe.config) - Removed test commands. - Added !pages to retrieve the list of pages from the server. (Will cause an exception if not running Sphere56) - Added '!page delete x' to delete a page from IRC. - Added LogManager, which saves particular information from the server and stores it for a week in a database. - Added 'Log...' PrivateCommands, '/msg bot log' for list. - Staff ChannelCommands now require 'StaffChan' property (set as true) on the channel to work. Index: BanSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/PunishSystem/BanSystem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BanSystem.cs 21 Jan 2005 03:29:53 -0000 1.1 --- BanSystem.cs 15 Feb 2005 21:47:28 -0000 1.2 *************** *** 100,104 **** SaveDatabase(); ! m_Server.CustomEvent += new EventHandler(OnCustomEvent); } #endregion --- 100,105 ---- SaveDatabase(); ! //m_Server.CustomEvent += new EventHandler(OnCustomEvent); ! m_Server.ClientKICKed += new ClientKICKedEventHandler(OnClientKICKed); } #endregion *************** *** 289,293 **** return false; ! Log.WriteLine("Sphere (BanDB)", "Account '{0}' is banned by {1}! (Reason: {3})", account, gm, reason); return true; } --- 290,294 ---- return false; ! Log.WriteLine("Sphere (BanDB)", "Account '{0}' is banned by {1}! (Reason: {2})", account, gm, reason); return true; } *************** *** 371,406 **** #endregion ! private void OnCustomEvent(object sender, EventArgs args) ! { ! /* ! if(args is PlayerBannedEventArgs) ! OnPlayerBanned(sender, (PlayerBannedEventArgs) args); ! else if(args is PlayerUnBannedEventArgs) ! OnPlayerUnBanned(sender, (PlayerUnBannedEventArgs) args);*/ ! } ! ! /* private void OnPlayerBanned(object sender, PlayerBannedEventArgs args) ! { ! ! string account = m_Server.GetItemProperty(args.Message.Player, "account"); ! string character = m_Server.GetItemProperty(args.Message.Player, "name"); ! string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! ! if (!Ban(account, character, gm, args.Message.Reason)) ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Ban Account '{0}'.", account); ! ! } ! ! private void OnPlayerUnBanned(object sender, PlayerUnBannedEventArgs args) { ! ! string account = m_Server.GetItemProperty(args.Message.Player, "account"); ! string gm = m_Server.GetItemProperty(args.Message.GM, "name"); ! ! if (!UnBan(account, gm)) ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to UnBan Account '{0}'.", account); ! } - */ } } --- 372,380 ---- #endregion ! private void OnClientKICKed(object sender, ClientKICKedEventArgs args) { ! if (!AddEntry(args.Message.Account, null, args.Message.Staff, "")) ! Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to add Ban '{0}' to database.", args.Message.Account); } } } Index: JailSystem.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/PunishSystem/JailSystem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JailSystem.cs 21 Jan 2005 03:29:53 -0000 1.1 --- JailSystem.cs 15 Feb 2005 21:47:28 -0000 1.2 *************** *** 390,393 **** --- 390,395 ---- #endregion + #region Event handlers + private void OnCustomEvent(object sender, EventArgs args) { *************** *** 416,419 **** --- 418,423 ---- Kernel.Instance.Network.SendChannelMessage(m_Parent.InnerConfig.OutputChannel, "Unable to Release Account '{0}'.", account); } + + #endregion } } |
From: Mr S. C. <mrs...@us...> - 2005-02-15 21:47:52
|
Update of /cvsroot/bobbot/Plugins/Sphere In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28988/Sphere Modified Files: SphereConfig.cs SpherePlugin.cs Log Message: - Ban System now registers bans made through scripts & .kick command. - Added <LogDatabase></LogDatabase> to the config. (should be added to bob.exe.config) - Removed test commands. - Added !pages to retrieve the list of pages from the server. (Will cause an exception if not running Sphere56) - Added '!page delete x' to delete a page from IRC. - Added LogManager, which saves particular information from the server and stores it for a week in a database. - Added 'Log...' PrivateCommands, '/msg bot log' for list. - Staff ChannelCommands now require 'StaffChan' property (set as true) on the channel to work. Index: SpherePlugin.cs =================================================================== RCS file: /cvsroot/bobbot/Plugins/Sphere/SpherePlugin.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SpherePlugin.cs 21 Jan 2005 03:41:02 -0000 1.15 --- SpherePlugin.cs 15 Feb 2005 21:47:28 -0000 1.16 *************** *** 1,2 **** ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); //Log.WriteLine("Sphere", args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); //if (m_Config.JailAutoSave) //bool properties don't work in the config? :s m_JailSystem.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Password: {1}", temp.Name, temp.Password); Kernel.Instance.Network.SendPrivateMessage(user, "Lang: {0} PLevel: {1}", temp.Lang, Account.PrivToString(temp.Plevel)); Kernel.Instance.Network.SendPrivateMessage(user, "FirstIP: {0} FirstDate: {1}", temp.FirstIP, temp.FirstConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "LastIP: {0} LastDate: {1}", temp.LastIP, temp.LastConnectDate); Kernel.Instance.Network.SendPrivateMessage(user, "Chars: {0} LastChar: 0{1:x}", temp.Chars, temp.LastCharUID); Kernel.Instance.Network.SendPrivateMessage(user, "TotalConnect: {0} LastConnect: {1}", temp.TotalConnectTime, temp.LastConnectTime); Kernel.Instance.Network.SendPrivateMessage(user, "Priv: 0{0:x}", temp.Priv); Kernel.Instance.Network.SendPrivateMessage(user, "Jailed: {0} Blocked: {1}", ((temp.Jailed)? "Yes" : "No"), ((temp.Blocked)? "Yes" : "No")); } return; } } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testitem")] private void testitemcommand(NetworkUser user, string[] args) { if (args.Length != 2) return; user.SendMessage("Value '{0}' for '{1}' is {2}", args[1], args[0], m_Server.GetItemProperty(Int32.Parse(args[0], System.Globalization.NumberStyles.HexNumber), args[1])); } [PrivateCommand("mypriv")] private void myprivcommand(NetworkUser user, string[] args) { user.SendNotice("Your priv is: {0}", Account.PrivToString(m_SphereAuth.GetStaffPriv(user))); return; } [PrivateCommand("liststaff")] private void liststaffcommand(NetworkUser user, string[] args) { foreach (Bot.Core.User staff in m_SphereAuth.StaffMembers()) user.SendNotice("{0}, {1}", staff.Name, Account.PrivToString((AccountPriv)staff.GetProperty("LothStaff"))); } [ChannelCommand("listchan")] private void ListChan(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "I am on the following channels:"); foreach(string channel in Kernel.Instance.Network.Channels.Keys) Kernel.Instance.Network.SendChannelMessage(chan, "\t\t{0}", channel); } #endregion #region 'Remote' Commands [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [RemoteCommand("account")] private static void RemoteAccountCommand(RemoteConnection sender, string[] args) { if (args.Length < 2) { sender.Send("Invalid Command or Format."); return; } if (args[0].ToLower() == "add") switch (args.Length) { case 2: { if (AccountRegistration.Instance.AccountAdd(args[1])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } case 3: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2])) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } default: { if (AccountRegistration.Instance.AccountAdd(args[1], args[2], Account.StringToPriv(args[3]))) sender.Send("Account {0} created successfully.", args[1]); else sender.Send("Unable to create account!"); return; } } else if (args[1].ToLower() == "delete") { if (AccountRegistration.Instance.AccountDel(args[0])) sender.Send("Account {0} deleted!", args[0]); ! else sender.Send("Unable to delete account!"); return; } else { string[] function = new string[ args.Length - 1 ]; Array.Copy(args, 1, function, 0, function.Length); sender.Send(AccountRegistration.Instance.AccountMod(args[0], function)); } } #endregion #region 'Staff' Commands [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!recon", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void ReconCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; if (m_Server.IsConnected) m_Server.Disconnect(); if (args.Length <= 0) m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); else m_Server.Connect(IPAddress.Parse(args[0]), m_Config.Port); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!discon", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void DisconCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; if (m_Server.IsConnected) m_Server.Disconnect(); else Kernel.Instance.Network.SendChannelMessage(chan, "Not Connected To Server."); } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!resync", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void ResyncCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) // return; m_Server.WriteLine("r"); m_Server.WriteLine("r"); Kernel.Instance.Network.SendChannelMessage(chan, "Done."); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!broadcast", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void BroadcastCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } string message = ""; foreach (string i in args) message += " " + i; m_Server.WriteLine("b" + message); Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "Broadcast: {0}", message); Log.WriteLine("Sphere", "Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!broadcastirc", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void BroadcastIrcCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; if (args.Length < 1) { Kernel.Instance.Network.SendChannelMessage(chan, "You didn't specify a message to send."); return; } string message = ""; foreach (string i in args) message += " " + i; Kernel.Instance.Network.SendChannelMessage(m_Config.PublicChannel, "IRC Broadcast: {0}", message); Log.WriteLine("Sphere", "IRC Broadcast:{0}", message); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!go", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void GoCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; if (args.Length < 2) { Kernel.Instance.Network.SendChannelMessage(chan, "Usage: !Go <uid> <message>"); return; } string message = ""; foreach (string i in args) { if (i != args[0]) message += " " + i; } m_Server.WriteLine("var.lothbot_target={0}", args[0]); m_Server.WriteLine("uid.{0}.respondtoplayer {1}", m_LothBotUid, message.Trim()); } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual, AllowConditionTarget.User)] [ChannelCommand("!resyncbot", Channels = new string[] {"#wp.uostaff", "#bob.bot", "#jockers" })] private void ResyncBotCommand(NetworkChannel chan, NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) // return; m_Timer.Stop(); m_Timer.Interval = 1; m_Timer.Start(); } [AllowCondition("LothStaff", AccountPriv.GM, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("admin listlog")] private void AdminListLogCommand(NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) // return; string[] logFiles = Directory.GetFiles(m_Config.LogDirectory, "*.log"); if(logFiles.Length == 0) { user.SendMessage("There are no log files available."); } else { user.SendMessage("The following log files are available:"); foreach(string log in logFiles) user.SendMessage("\t{0}", log); } } [AllowCondition("LothStaff", AccountPriv.Admin, AllowConditionUsage.GreaterThanOrEqual)] [PrivateCommand("addstaff")] private void AddStaffCommand(NetworkUser user, string[] args) { // if (!m_SphereAuth.IsStaff(user)) // return; // if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) // return; if (args.Length < 1) { user.SendMessage("You must at least provide an account name."); return; } else if (args.Length > 3) { user.SendMessage("Too many arguments provided! (AddStaff <Account> [<Priv>] [<Password>]"); return; } if (!m_Server.IsConnected) { user.SendMessage("Unable to add accounts whilst not connected to the server!"); return; } switch (args.Length) { case 1: { if (m_Accounting.AccountAdd(args[0], AccountPriv.Counselor)) user.SendMessage("Counselor account '{0}' created successfully! Password is '{1}'", args[0], "blah"); else user.SendMessage("Unable to create account!"); return; } case 2: { if (m_Accounting.AccountAdd(args[0], Account.StringToPriv(args[1]))) user.SendMessage("{1} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), "blah"); else user.SendMessage("Unable to create account!"); return; } case 3: { if (m_Accounting.AccountAdd(args[0], args[2], Account.StringToPriv(args[1]))) user.SendMessage("{2} account '{0}' created successfully! Password is '{2}'", args[0], Account.PrivToString(Account.StringToPriv(args[1])), args[2]); else user.SendMessage("Unable to create account!"); return; } } } #region Jail Commands [PrivateCommand("jail")] private void JailCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Jail <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Add <Account> <Length> [<Reason>]'"); return; } if (m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' is already jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.Jail(args[1], null, user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}' jailed for {1} hours!", args[1], args[2]); else user.SendNotice("Unable to jail '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Del <Account>'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } if (m_JailSystem.Release(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Jail Edit <Account> <Length> [<Reason>]'"); return; } if (!m_JailSystem.IsJailed(args[1])) { user.SendNotice("Account '{0}' wasn't jailed!", args[1]); return; } string jailargs = ""; for (int i = 3; i < args.Length; i++) jailargs += " " + args[i]; if (m_JailSystem.EditJail(args[1], user.Nickname, args[2], jailargs.Trim())) user.SendNotice("'{0}'s jail entry is edited!", args[1]); else user.SendNotice("Unable to edit jail entry '{0}'!", args[1]); return; } case "list": { if (m_JailSystem.JailedAccounts <= 0) { user.SendNotice("No Accounts are Jailed!"); return; } foreach (JailEntry entry in m_JailSystem.GetJailEntryList()) { user.SendNotice("Account: {0} Release Date: {1}", entry.Account, entry.JailedUntil.ToString()); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Info <Account>'"); return; } JailEntry entry = m_JailSystem.GetJailEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Jailed By: {0}", entry.JailedBy); user.SendNotice("Jail Date: {0}", entry.JailedOn); user.SendNotice("Release Date: {0} ({1})", entry.JailedUntil, entry.TimeLeft); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Jailed!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_JailSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Jail Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Add <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new jail database entry for <Account>. The account will"); user.SendNotice("automatically be jailed ingame."); user.SendNotice("The release date will be set <Length> hours after the jail"); user.SendNotice("time, and will automatically released from jail at that time."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Jail Add myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Add myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically released ingame."); user.SendNotice("Example: /msg {0} Jail Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Edit <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the"); user.SendNotice("entry's length to <Length> hours."); user.SendNotice("If [<Reason>] is provided then this will also be amended."); user.SendNotice("The 'Jailed By' property of the jail entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice("Example: /msg {0} Jail Edit myAccount 24", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Jail Edit myAccount 24 Jailed for bug abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Jail Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Jail Database to be saved immediately. Unsaved jail"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Jail Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Jail List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently jailed accounts, along with"); user.SendNotice("their release dates. For more information on a jail entry, use"); user.SendNotice("Jail Info"); user.SendNotice("Example: /msg {0} Jail List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Jail Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s jail entry."); user.SendNotice("Example: /msg {0} Jail Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Jail Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Jail Info Displays jail entry information"); user.SendNotice("Jail List Displays full list of jailed accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Jail Add Jails an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Jail Del Releases an account from jail."); user.SendNotice("Jail Edit Edits an account entry."); if (m_SphereAuth.GetStaffPriv(user) >= AccountPriv.Admin) user.SendNotice("Jail Save Forces the Jail Database to be saved."); } return; } } } #endregion #region Ban Commands [PrivateCommand("ban")] private void BanCommand(NetworkUser user, string[] args) { if (args.Length <= 0) { user.SendNotice("Incorrect Usage. (Ban <command> [<arguments>])"); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } switch (args[0].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Add <Account> <Length> [<Reason>]'"); return; } if (m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' is already banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.Ban(args[1], null, user.Nickname, banargs.Trim())) user.SendNotice("'{0}' banned!", args[1]); else user.SendNotice("Unable to ban '{0}'", args[1]); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Del <Account>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } if (m_BanSystem.UnBan(args[1], user.Nickname)) user.SendNotice("'{0}' released!", args[1]); else user.SendNotice("Unable to release '{0}'", args[1]); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("You cannot use this command."); return; } if (args.Length < 3) { user.SendNotice("Incorrect Arguments: 'Ban Edit <Account> <Length> <Reason>'"); return; } if (!m_BanSystem.IsBanned(args[1])) { user.SendNotice("Account '{0}' wasn't banned!", args[1]); return; } string banargs = ""; for (int i = 2; i < args.Length; i++) banargs += " " + args[i]; if (m_BanSystem.EditBan(args[1], user.Nickname, banargs.Trim())) user.SendNotice("'{0}'s ban entry is edited!", args[1]); else user.SendNotice("Unable to edit ban entry '{0}'!", args[1]); return; } case "list": { if (m_BanSystem.BannedAccounts <= 0) { user.SendNotice("No Accounts are Banned!"); return; } foreach (BanEntry entry in m_BanSystem.GetBanEntryList()) { user.SendNotice("Account: {0}", entry.Account); } return; } case "info": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Info <Account>'"); return; } BanEntry entry = m_BanSystem.GetBanEntry(args[1]); if (entry != null) { user.SendNotice("Account: {0}", entry.Account); user.SendNotice("Character: {0}", entry.Character); user.SendNotice("Banned By: {0}", entry.BannedBy); user.SendNotice("Ban Date: {0}", entry.BannedOn); user.SendNotice("Reason: {0}", entry.Reason); } else user.SendNotice("Account '{0}' Not Banned!", args[1]); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("You cannot use this command."); return; } if (m_BanSystem.SaveDatabase()) user.SendNotice("Database Saved Successfully."); else user.SendNotice("Database Failed to Save!"); return; } case "help": { if (args.Length < 2) { user.SendNotice("Incorrect Arguments: 'Ban Help <Command>'"); return; } switch (args[1].ToLower()) { case "add": { if (!m_SphereAuth.IsStaff(user)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Add <Account> <Length> [<Reason>]", Kernel.Instance.Network.Nickname); user.SendNotice("Adds a new ban database entry for <Account>. The account will"); user.SendNotice("automatically be banned ingame."); user.SendNotice("The <Reason> argument is saved into the database for all users"); user.SendNotice("to view. This is optional and can be left out if not desired."); user.SendNotice("Example: /msg {0} Ban Add myAccount", Kernel.Instance.Network.Nickname); user.SendNotice(" /msg {0} Ban Add myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "del": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Del <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Deletes the entry for <Account> from the database. The account"); user.SendNotice("will automatically be unbanned ingame."); user.SendNotice("Example: /msg {0} Ban Del myAccount", Kernel.Instance.Network.Nickname); return; } case "edit": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Edit <Account> <Reason>", Kernel.Instance.Network.Nickname); user.SendNotice("Edits the entry for <Account> in the database, exchanging the."); user.SendNotice("current Reason to <Reason>."); user.SendNotice("The 'Banned By' property of the ban entry will be amended to "); user.SendNotice("indicate that the entry has been amended by another staff"); user.SendNotice("member if that is the case."); user.SendNotice(" /msg {0} Ban Edit myAccount Banned for injection abuse.", Kernel.Instance.Network.Nickname); return; } case "save": { if (!m_SphereAuth.IsStaff(user) || (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin)) { user.SendNotice("No help is available for this command."); return; } user.SendNotice("/msg {0} Ban Save", Kernel.Instance.Network.Nickname); user.SendNotice("Forces the Ban Database to be saved immediately. Unsaved ban"); user.SendNotice("entries will result in players not being released if the Bot"); user.SendNotice("is restarted."); user.SendNotice("Example: /msg {0} Ban Save", Kernel.Instance.Network.Nickname); return; } case "list": { user.SendNotice("/msg {0} Ban List", Kernel.Instance.Network.Nickname); user.SendNotice("Displays a list of all the currently banned accounts, along with"); user.SendNotice("their release dates. For more information on a ban entry, use"); user.SendNotice("Ban Info"); user.SendNotice("Example: /msg {0} Ban List", Kernel.Instance.Network.Nickname); return; } case "info": { user.SendNotice("/msg {0} Ban Info <Account>", Kernel.Instance.Network.Nickname); user.SendNotice("Displays information on <Account>'s ban entry."); user.SendNotice("Example: /msg {0} Ban Info myAccount", Kernel.Instance.Network.Nickname); return; } default: { user.SendNotice("No help is available for this command."); return; } } } default: { user.SendNotice("Unknown Command '{0}'", args[0]); user.SendNotice("Following commands are available to you"); user.SendNotice("Use 'Ban Help <command>' for more information"); user.SendNotice("------------------------------------------------"); user.SendNotice("Ban Info Displays ban entry information"); user.SendNotice("Ban List Displays full list of banned accounts."); if (m_SphereAuth.IsStaff(user)) { user.SendNotice("Ban Add Bans an account."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.GM) return; user.SendNotice("Ban Edit Edits a ban entry."); if (m_SphereAuth.GetStaffPriv(user) < AccountPriv.Admin) return; user.SendNotice("Ban Del Unbans an account."); user.SendNotice("Ban Save Forces the Ban Database to be saved."); } return; } } } #endregion #endregion #region 'Player' Commands [ChannelCommand("!stats")] private void StatsCommand(NetworkChannel chan, NetworkUser user, string[] args) { user.SendNotice("Peak Clients: {0}", SphereConnection.Instance.ClientCount); user.SendNotice("Players Connected: {0}", m_ConnectCount); user.SendNotice("Players Died: {0}", m_KillCount); user.SendNotice("Pages Received: {0}", m_PageCount); user.SendNotice("Commands Issued: {0}", m_ClientCommandsCount); user.SendNotice("World Saves: {0}", m_WorldSaveCount); } [ChannelCommand("!clients")] private void ClientsCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, String.Format("The current client count is {0}", SphereConnection.Instance.ClientCount)); } [ChannelCommand("!status")] private void StatusCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, String.Format("Connection Status: {0} ({1}:{2}) - http://{1}:{2}/status.html", (m_Server.IsConnected) ? "Connected" : "Not Connected", m_Config.Address, m_Config.Port)); } [ChannelCommand("!jail")] private void JailCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "The Lothlorien Jail List is: http://central.wireplay.co.uk/bans/index.php?game=52"); } [ChannelCommand("!forum")] private void ForumCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "Forums for Lothlorien can be found at http://forums.wireplay.co.uk/forumdisplay.php3?forumid=299"); } [ChannelCommand("!url")] private void UrlCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "The Lothlorien website can be found at http://Lothlorien.wireplay.co.uk"); } [ChannelCommand("!uoa")] private void UOACommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "UO Assist Key: tN2qD8,$MEd8,=je,4XrG,V}}9d,2fK]j,[Tu~,TXYK,+r"); } [ChannelCommand("!lastkill")] private void LastKillCommand(NetworkChannel chan, NetworkUser user, string[] args) { string m_Killers = ""; for (int i = 0; i < m_LastKillers.Length; i++) { m_Killers += String.Format(" 5({0}) {1},", (m_LastKillers[i].Type == MobileType.Player? "Player":"Monster"), m_LastKillers[i].Name); } m_Killers = m_Killers.Substring(0, m_Killers.Length - 1); Kernel.Instance.Network.SendChannelMessage(chan, String.Format("12({0}) {1} was killed by {2}", (m_LastVictim.Type == MobileType.Player)? "Player" : "NPC", m_LastVictim.Name, m_Killers.Trim().Length <= 0? m_LastVictim.Name : m_Killers.Trim())); } [ChannelCommand("!peak")] private void PeakCommand(NetworkChannel chan, NetworkUser user, string[] args) { Kernel.Instance.Network.SendChannelMessage(chan, "The peak clients is {0}", m_ClientPeak); } #endregion } } \ No newline at end of file --- 1,150 ---- ! #region LGPL License /* Bastard of a Bot Library Copyright (C) 2004 Bastard of a Bot Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #endregion using System; using System.IO; using System.Net; using System.Collections; using System.Configuration; using System.Timers; using Bot.Core; using Bot.Core.Irc; using Bot.Core.Irc.Messages; using Bot.Core.RemoteAdmin; using Bot.Plugins.Sphere; using Bot.Plugins.Sphere.Messages; using Bot.Plugins.Sphere.PunishSystem; using Bot.Plugins.Sphere.Accounting; using Bot.Plugins.Sphere.LogManagement; using Bot.Other.Sphere; using Bot.Other.Sphere.Messages; namespace Bot.Plugins.Sphere { public class SpherePlugin : MarshalByRefObject, IPlugin { #region Private members private SphereConfig m_Config; private SphereAuth m_SphereAuth; private SphereConnection m_Server; private AccountRegistration m_Accounting; private JailSystem m_JailSystem; private BanSystem m_BanSystem; private LogManager m_LogManager; private int m_KillCount; private int m_PageCount; private int m_ClientPeak; private int m_ConnectCount; private int m_WorldSaveCount; private int m_ClientCommandsCount; private string m_LothBotUid; private Mobile m_LastVictim; private Mobile[] m_LastKillers; private Timer m_Timer; private DateTime m_LogNextOpen; private StreamWriter m_CurrentLog; #endregion #region Public properties public SphereConfig InnerConfig { get { return m_Config; } } public SphereConnection InnerConnection { get { return m_Server; } } #endregion #region IPlugin implementation public string Name { get { return "Sphere"; } } public string Author { get { return "Iain Mckay <jo...@wi...>"; } } public void Start() { m_Config = (SphereConfig) ConfigurationSettings.GetConfig("SphereConfig"); m_PageCount = 0; m_ClientPeak = 0; m_ConnectCount = 0; m_WorldSaveCount = 0; m_ClientCommandsCount = 0; m_LothBotUid = ""; if (File.Exists("peak.txt")) { StreamReader peakRead = File.OpenText("peak.txt"); string line = peakRead.ReadLine(); while (line != null) { if (line.StartsWith("PEAK")) { m_ClientPeak = Int32.Parse(line.Remove(0, 5)); } line = peakRead.ReadLine(); } peakRead.Close(); } m_Timer = new Timer(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.AutoReset = true; m_Timer.Enabled = true; m_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); m_LogNextOpen = DateTime.Now; m_Server = SphereConnection.Instance; m_Server.CustomLog += new CustomLogEventHandler(OnCustomLog); m_Server.ShowValue += new ShowValueEventHandler(OnShowValue); m_Server.ScriptError += new ScriptErrorEventHandler(OnScriptError); m_Server.WorldSave += new WorldSaveEventHandler(OnWorldSave); m_Server.ClientPage += new ClientPageEventHandler(OnClientPage); m_Server.ClientKilled +=new ClientKilledEventHandler(OnClientKilled); m_Server.Connected += new ConnectedEventHandler(OnConnected); m_Server.Disconnected += new DisconnectedEventHandler(OnDisconnected); m_Server.ConnectionLost += new DisconnectedEventHandler(OnConnectionLost); m_Server.AdminWelcome += new AdminWelcomeEventHandler(OnAdminWelcome); m_Server.ClientCommand += new ClientCommandEventHandler(OnClientCommand); m_Server.ConnectionFailed += new DisconnectedEventHandler(OnConnectionFailed); m_Server.MessageReceived += new MessageReceivedEventHandler(OnMessageReceived); m_Server.AdminBadPassword += new AdminBadPasswordEventHandler(OnAdminBadPassword); m_Server.AdminAccountInUse += new AdminAccountInUseEventHandler(OnAdminAccountInUse); m_Server.ClientConnected += new ClientConnectedEventHandler(OnClientConnected); Bot.Core.Kernel.Instance.Network.Welcome += new WelcomeReplyEventHandler(OnNetworkWelcome); m_LastVictim = new Mobile(MobileType.Player, "Victim"); m_LastKillers = new Mobile[] { new Mobile(MobileType.Npc, "Aggressor") }; m_Server.Password = m_Config.Password; m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem = new JailSystem(this, m_Config.JailDatabase); m_BanSystem = new BanSystem(this, m_Config.BanDatabase); m_Accounting = new AccountRegistration(m_Server, m_Config.AccountDatabase); m_SphereAuth = new SphereAuth(this); m_LogManager = new LogManager(m_Server, m_Config.LogDatabase); } public void Stop() { if(m_Server != null) { m_Server.Disconnect(); m_Server = null; } } #endregion #region Event handlers private void OnConnected(object sender, ConnectedEventArgs args) { Log.WriteLine("Sphere", "Connected to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connected to '{0}'", args.EndPoint.ToString())); } private void OnDisconnected(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Disconnected from '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Disconnected from '{0}'", args.EndPoint.ToString())); } private void OnConnectionLost(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Connection lost to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Connection lost to '{0}'", args.EndPoint.ToString())); } private void OnConnectionFailed(object sender, DisconnectedEventArgs args) { Log.WriteLine("Sphere", "Failed to connect to '{0}'", args.EndPoint.ToString()); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, String.Format("Failed to connect to '{0}'", args.EndPoint.ToString())); } private void OnAdminWelcome(object sender, AdminWelcomeEventArgs args) { Log.WriteLine("Sphere", "Signed onto the administration console"); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Signed onto the administration console"); m_Server.WriteLine("show clients"); m_Server.WriteLine("show var.lothbot_uid"); /*string clicount = (string)m_GetValue.GetProperty("clients"); if (clicount != null) m_ClientCount = Int32.Parse(clicount); string botuid = (string)m_GetValue.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid;*/ } private void OnAdminBadPassword(object sender, AdminBadPasswordEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, bad password."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, bad password."); m_Server.Disconnect(); } private void OnAdminAccountInUse(object sender, AdminAccountInUseEventArgs args) { Log.WriteLine("Sphere", "Could not sign in, account in use."); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Could not sign in, account in use."); m_Server.Disconnect(); } private void OnClientPage(object sender, ClientPageEventArgs args) { Log.WriteLine("Sphere", "Page from '{0}': {1}", args.Message.Character, args.Message.Page); string pageStr = String.Format("Page from {0} [{1}] at {2}: {3}", args.Message.Character, args.Message.Serial, args.Message.Position.ToString(), args.Message.Page); Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, pageStr); } private void OnClientKilled(object sender, ClientKilledEventArgs args) { m_KillCount++; m_LastVictim = args.Message.Victim; m_LastKillers = args.Message.Aggressors; } private void OnClientCommand(object sender, ClientCommandEventArgs args) { m_ClientCommandsCount++; } private void OnWorldSave(object sender, WorldSaveEventArgs args) { m_WorldSaveCount++; } private void OnMessageReceived(object sender, MessageReceivedEventArgs args) { // If we have passed midnight or we don't have a logfile open, open new log file. if((m_LogNextOpen <= DateTime.Now) || (m_CurrentLog == null)) { if(m_CurrentLog != null) { m_CurrentLog.Close(); m_CurrentLog = null; } string logFile = Path.Combine(m_Config.LogDirectory, String.Format("{0}-{1}-{2}.log", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day)); try { m_CurrentLog = new StreamWriter(logFile, true); m_CurrentLog.AutoFlush = true; m_CurrentLog.WriteLine("---------------------------------------------------------------"); m_CurrentLog.WriteLine("Log opened at {0} on {1}", DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongDateString()); m_CurrentLog.WriteLine("---------------------------------------------------------------"); Log.WriteLine("Sphere", "Rotated log file"); m_LogNextOpen = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); m_LogNextOpen = m_LogNextOpen.AddDays(1); } catch(Exception ex) { Log.WriteLine("Sphere", "Could not rotate log file, {0}", ex.Message); } } if(m_CurrentLog != null) m_CurrentLog.WriteLine(args.Message); //Log.WriteLine("Sphere", args.Message); } private void OnShowValue(object sender, ShowValueEventArgs args) { if((args.Message.Property.ToLower() == "var.lothbot_uid") && (args.Message.Value.Trim() != "")) m_LothBotUid = args.Message.Value; } private void OnScriptError(object sender, ScriptErrorEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Error); return; } //Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, "Error! Time:{0} Script:{1} Line:{2} Error:{3}", args.Message.Time.ToString(), args.Message.Script, args.Message.LineNumber.ToString(), args.Message.Error); } private void OnCustomLog(object sender, CustomLogEventArgs args) { if (args.Message.Script == "botgmnpc.scp") { Kernel.Instance.Network.SendChannelMessage(m_Config.OutputChannel, args.Message.Message); return; } } private void OnTimerElapsed(object sender, ElapsedEventArgs e) { if (m_Server.IsConnected) { string botuid = (string) m_Server.GetProperty("var.lothbot_uid"); if (botuid != null && botuid.Trim() != "") m_LothBotUid = botuid; } else m_Server.Connect(IPAddress.Parse(m_Config.Address), m_Config.Port); m_JailSystem.SaveDatabase(); m_BanSystem.SaveDatabase(); m_LogManager.SaveDatabase(); if (File.Exists("peak.txt")) File.Delete("peak.txt"); StreamWriter peakWrite = File.CreateText("peak.txt"); peakWrite.Write("PEAK={0}", m_ClientPeak); peakWrite.Close(); if (m_Timer.Interval == 1) { m_Timer.Stop(); m_Timer.Interval = m_Config.ResyncPeriod; m_Timer.Start(); } } ! ! private void OnClientConnected(object sender, ClientConnectedEventArgs args) ! { ! if (args.Message.ClientCount > m_ClientPeak) ! m_ClientPeak = args.Message.ClientCount; ! } #endregion #region Test/Temp Commands [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testval")] private void testvalcommand(NetworkUser user, string[] args) { object o; if (args.Length <= 0) o = m_Server.GetProperty("uid.1.name"); else o = m_Server.GetProperty(args[0]); Kernel.Instance.Network.SendPrivateMessage(user, "Value is '{0}'", (string)o); } [AllowCondition("LothStaff", AccountPriv.Owner, AllowConditionUsage.Equals)] [PrivateCommand("testaccount")] private void testcommand(NetworkUser user, string[] args) { if (args.Length <= 0) m_Server.WriteLine("account blah show {0}", m_Server.ValidAccountProperties[new Random().Next(0, m_Server.ValidAccountProperties.Count)]); else { if (!m_Accounting.AccountExists(args[0])) Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist!", args[0]); else { Account temp = m_Accounting.GetAccount(args[0]); if (temp == null) { Kernel.Instance.Network.SendPrivateMessage(user, "Account '{0}' doesn't exist! (Error? :s)", args[0]); return; } Kernel.Instance.Network.SendPrivateMessage(user, "Account: {0} Passwor... [truncated message content] |