Ejemplo n.º 1
0
 /// <summary>
 /// Enqueue a message to send a WhoX query for the nickname.
 /// and a nickname.
 /// </summary>
 /// <param name="Name"></param>
 public void UserRegCheck(string Name)
 {
     if (Name != string.Empty)
     {
         WhoXQueryQueue.Enqueue(Name);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Overwritten Init method.
        /// This method connects to the M59 server.
        /// So we connect to IRC here as well.
        /// </summary>
        public override void Init()
        {
            // base handler connecting to m59 server
            base.Init();

            // create IRC command queues
            ChatCommandQueue  = new LockingQueue <string>();
            AdminCommandQueue = new LockingQueue <string>();
            WhoXQueryQueue    = new WhoXQueryQueue();

            // Whether bot echoes to IRC or not.
            DisplayMessages = true;

            // Create list for keeping track of user registration.
            UserRegistration = new Dictionary <string, bool>();

            // Init list of recent admins to send a command.
            RecentAdmins = new List <string>();

            // create an IRC client instance
            IrcClient = new StandardIrcClient();
            IrcClient.FloodPreventer = new FloodPreventer(Config.MaxBurst, Config.Refill);

            // hook up IRC client event handlers
            // beware! these are executed by the internal workthread
            // of the library.
            IrcClient.Connected         += OnIrcClientConnected;
            IrcClient.ConnectFailed     += OnIrcClientConnectFailed;
            IrcClient.Disconnected      += OnIrcClientDisconnected;
            IrcClient.Registered        += OnIrcClientRegistered;
            IrcClient.ProtocolError     += OnIrcClientProtocolError;
            IrcClient.WhoXReplyReceived += OnWhoXReplyReceived;

            // build our IRC connection info
            IrcUserRegistrationInfo regInfo = new IrcUserRegistrationInfo();

            regInfo.UserName = Config.NickName;
            regInfo.RealName = Config.NickName;
            regInfo.NickName = Config.NickName;

            // if password is set
            if (!String.Equals(Config.IRCPassword, String.Empty))
            {
                regInfo.Password = Config.IRCPassword;
            }

            // log IRC connecting
            Log("SYS", "Connecting IRC to " + Config.IRCServer + ":" + Config.IRCPort);

            // connect the lib internally (this is async)
            IrcClient.Connect(Config.IRCServer, Config.IRCPort, false, regInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Overwritten Init method.
        /// This method connects to the M59 server.
        /// So we connect to IRC here as well.
        /// </summary>
        public override void Init()
        {
            // base handler connecting to m59 server
            base.Init();

            // create IRC command queues
            ChatCommandQueue  = new LockingQueue <string>();
            AdminCommandQueue = new LockingQueue <string>();
            IRCSendQueue      = new IRCQueryQueue();
            WhoXQueryQueue    = new WhoXQueryQueue();

            // Whether bot echoes to IRC or not.
            DisplayMessages = true;

            // Create list for keeping track of user registration.
            UserRegistration = new Dictionary <string, bool>();

            // Init list of recent admins to send a command.
            RecentAdmins = new List <string>();

            // create an IRC client instance, with connection info
            IrcClient = new IrcClient(Config.IRCServer,
                                      new IrcUser(Config.NickName, Config.NickName, Config.IRCPassword, Config.NickName));

            // TODO: does ChatSharp use something like this?
            //IrcClient.FloodPreventer = new FloodPreventer(Config.MaxBurst, Config.Refill);

            // hook up IRC client event handlers
            // beware! these are executed by the internal workthread
            // of the library.
            IrcClient.ConnectionComplete += OnIrcClientConnected;

            // ChatSharp doesn't have fine-grained error handling
            // to my knowledge, likely we have to disconnect on any
            // network error.
            IrcClient.NetworkError += OnIrcClientDisconnected;

            IrcClient.WhoxReceived += OnWhoXReplyReceived;

            // log IRC connecting
            Log("SYS", "Connecting IRC to " + Config.IRCServer + ":" + Config.IRCPort);

            // connect the lib internally (this is async)
            IrcClient.ConnectAsync();
        }