Пример #1
0
        /// <summary>
        /// Stops the chat bot
        /// </summary>
        public void StopBot()
        {
            //Check to see that the bot has not already been stopped
            if (!_running)
            {
                return;
            }

            //Turn off the Identd server
            if (Identd.IsRunning())
            {
                Identd.Stop();
            }

            //Disconnects the IRC bot
            if (_irc.Connected)
            {
                _irc.Disconnect("Bot Stopped");
            }

            //Clear user lists
            ResetUsers();

            //Set running flag to false
            _running = false;
        }
Пример #2
0
        /// <summary>
        /// Method called upon the irc connection registering to the IRC server
        /// </summary>
        private void IrcRegistered()
        {
            //Turn off the Identd Server
            if (Identd.IsRunning())
            {
                Identd.Stop();
            }

            //Join the corresponding channel
            _irc.Sender.Join("#" + _channel.ToLower());
        }
Пример #3
0
        /// <summary>
        /// Method called upon the irc connection registering to the IRC server
        /// </summary>
        private void IrcRegistered()
        {
            //Turn off the Identd Server
            if (Identd.IsRunning())
            {
                Identd.Stop();
            }

            //Join the corresponding channel
            _irc.Sender.Join("#" + _channel.ToLower());
            HandleEvent(string.Format("Connected! Joining #{0}", _channel.ToLower()), EventListItem.SuccessColor);
        }
Пример #4
0
        /// <summary>
        /// Starts the chat bot with pre-designated settings
        /// </summary>
        public bool StartBot()
        {
            //Check to see that the bot has not already been started
            if (_running)
            {
                return(false);
            }

            //Check requirements
            if (string.IsNullOrEmpty(_botUsername))
            {
                throw new Exception("No bot account info defined");
            }

            //Reset user lists
            ResetUsers();

            //Starts the Identd server - Not necessary, but may be implemented by Twitch at some point
            if (!Identd.IsRunning())
            {
                Identd.Start(_botUsername);
            }
            _irc = new Connection(GetConnArgs(), false, false);

            //Setup irc listeners
            _irc.Listener.OnRegistered        += IrcRegistered;
            _irc.Listener.OnNames             += IrcOnNames;
            _irc.Listener.OnJoin              += IrcJoined;
            _irc.Listener.OnPart              += IrcPart;
            _irc.Listener.OnPublic            += IrcPublic;
            _irc.Listener.OnPrivate           += IrcPrivate;
            _irc.Listener.OnChannelModeChange += Listener_OnChannelModeChange;
            _irc.Listener.OnError             += Listener_OnError;

            try
            {
                //Attempt a connection the server
                _irc.Connect();

                //Set running flag to true
                _running = true;
            }
            catch (SocketException ex)
            {
                //throw new Exception("Unable to connect to the IRC server");
                return(false);
            }
            return(true);
        }