[Bobbot-cvs] Bob/Core/Irc/Messages/Replies NameReply.cs,NONE,1.1
Status: Alpha
Brought to you by:
iainmckay
From: Iain M. <iai...@us...> - 2005-01-16 03:16:32
|
Update of /cvsroot/bobbot/Bob/Core/Irc/Messages/Replies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31224/Core/Irc/Messages/Replies Added Files: NameReply.cs Log Message: Too many changes to list. The most important change is the new style for defining command handlers. A command handler can now have variable arguments and of variable types, the kernel will automatically convert the text arguments to what you expect. Such an example is: public void MyTestCommand(NetworkChannel chan, NetworkUser user, string userName, bool enableAccount); This would cause the kernel to convert the second argument to a bool. You can also have a catchall argument to catch any extra arguments typed by the user, this is just a string array: public void MyTestCommand(NetworkChannel chan, NetworkUser user, string userName, bool enableAccount, string[] args); --------------------------------------- The NetworkConnection now tracks users across joins, parts, etc. It does not however track mode changes at the moment. NetworkUser and NetworkChannel have events associated with them. --------------------------------------- Check the diffs for full change details. --- NEW FILE: NameReply.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 Bot.Core.Irc; using Bot.Core.Irc.Exceptions; using Bot.Core.Irc.Collections; namespace Bot.Core.Irc.Messages { /// <summary> /// Summary description for NameReply. /// </summary> public class NameReply : BaseMessage { #region Public properties public override int NumericReply { get { return 353; } } public NetworkChannel Channel { get{ return ((NetworkChannel) Parameters[2]); } } public UserCollection Users { get { return m_Users; } } #endregion #region Private members private UserCollection m_Users; #endregion #region Constructor public NameReply() : base() { m_Users = new UserCollection(); } #endregion #region Public methods public override void Notify(NetworkConnection toNotify) { toNotify.OnNameReply(new NameReplyEventArgs(this)); } public override bool Parse(string rawMsg) { if(!base.Parse(rawMsg)) return false; Parameters[2] = Kernel.Instance.Network.GetChannel((string) Parameters[2]); string[] users = ((string) Parameters[3]).Split(' '); foreach(string user in users) { string realUser; if(user.StartsWith("@") || user.StartsWith("+")) realUser = user.Substring(1); else realUser = user; m_Users.Add(Kernel.Instance.Network.GetUser(realUser)); } return true; } #endregion } public delegate void NameReplyEventHandler(NetworkConnection network, NameReplyEventArgs args); public class NameReplyEventArgs : EventArgs { #region Public properties public NameReply Message { get { return m_Message; } } #endregion #region Private members private NameReply m_Message; #endregion #region Constructor public NameReplyEventArgs(NameReply message) { m_Message = message; } #endregion } } |