示例#1
0
 public void SetUp()
 {
     ConnectionArgs args = new ConnectionArgs("deltabot","irc.sventech.com");
     connection = new Connection( args );
     RegisterListeners();
     AssignLines();
 }
示例#2
0
        public TwitchChatBot()
        {
            XDocument doc = XDocument.Load("twitch.config");
            XElement configElement = doc.Element("configuration");
            XElement serverElement = configElement.Element("Server");
            Credentials.Server = serverElement.Value;
            XElement channelElement = configElement.Element("Channel");
            Credentials.Channel = channelElement.Value;
            XElement nickElement = configElement.Element("Nick");
            Credentials.Nick = nickElement.Value;
            XElement passwordElement = configElement.Element("Password");
            Credentials.Password = passwordElement.Value;
            XElement commandsElement = configElement.Element("Commands");
            foreach(XElement commandElement in commandsElement.Elements())
            {
                commands.Add("!" + commandElement.Name.LocalName.ToLower(), commandElement.Value);
            }

            ConnectionArgs cargs = new ConnectionArgs(Credentials.Nick, Credentials.Server);
            cargs.Port = 6667;
            cargs.ServerPassword = Credentials.Password;

            connection = new Connection(cargs, false, false);

            connection.Listener.OnRegistered += new RegisteredEventHandler(OnRegistered);
            connection.Listener.OnJoin += new JoinEventHandler(OnJoin);
            connection.Listener.OnPublic += new PublicMessageEventHandler(OnPublic);
            //Listen for bot commands sent as private messages
            connection.Listener.OnPrivate += new PrivateMessageEventHandler(OnPrivate);
            //Listen for notification that an error has ocurred
            connection.Listener.OnError += new ErrorMessageEventHandler(OnError);

            //Listen for notification that we are no longer connected.
            connection.Listener.OnDisconnected += new DisconnectedEventHandler(OnDisconnected);
        }
示例#3
0
 /// <summary>
 /// Used for internal test purposes only.
 /// </summary>
 internal Connection(ConnectionArgs args)
 {
     connectionArgs = args;
     sender         = new Sender(this);
     listener       = new Listener();
     timeLastSent   = DateTime.Now;
     EnableCtcp     = true;
     EnableDcc      = true;
     TextEncoding   = Encoding.Default;
 }
示例#4
0
 /// <summary>
 /// Prepare a connection to an IRC server but do not open it. This sets the text Encoding to Default.
 /// </summary>
 /// <param name="args">The set of information need to connect to an IRC server</param>
 /// <param name="textEncoding">The text encoding for the incoming stream.</param>
 public Connection(Encoding textEncoding, ConnectionArgs args)
 {
     registered        = false;
     connected         = false;
     handleNickFailure = true;
     connectionArgs    = args;
     sender            = new Sender(this);
     listener          = new Listener( );
     RegisterDelegates();
     TextEncoding = textEncoding;
 }
示例#5
0
        private void CreateConnection()
        {
            string server = "irc.ppy.sh";

            string nick = Form1._Username.ToLower();
            string password = Form1._Password;

            ConnectionArgs cargs = new ConnectionArgs(nick, server) { Nick = nick, UserName = nick, ServerPassword = password };

            connection = new Connection(cargs, false, false);
        }
示例#6
0
        public TwitchBot()
        {
            channelList = new HashSet<String>();

            ConnectionArgs cargs = new ConnectionArgs(Settings.Default.IrcName, Settings.Default.IrcServer)
            {
                Port = Settings.Default.Port,
                ServerPassword = Settings.Default.IrcPassword
            };

            log.Info($"Trying to connect to {cargs.Hostname}:{cargs.Port} as {Settings.Default.IrcName}");

            connection = new Connection(cargs, false, false);

            connection.Listener.OnRegistered += new RegisteredEventHandler(OnRegistered);
            connection.Listener.OnRegistered += new RegisteredEventHandler(ResetHeartbeatMonitor);

            connection.Listener.OnPublic += new PublicMessageEventHandler(OnPublic);
            connection.Listener.OnPublic += new PublicMessageEventHandler((a, b, c) => ResetHeartbeatMonitor());

            //Listen for bot commands sent as private messages
            connection.Listener.OnPrivate += new PrivateMessageEventHandler(OnPrivate);
            connection.Listener.OnPrivate += new PrivateMessageEventHandler((a, b) => ResetHeartbeatMonitor());

            //Listen for notification that an error has ocurred
            connection.Listener.OnError += new ErrorMessageEventHandler(OnError);

            //Listen for notification that we are no longer connected.
            connection.Listener.OnDisconnected += new DisconnectedEventHandler(OnDisconnected);
            connection.Listener.OnDisconnecting += new DisconnectingEventHandler(OnDisconnecting);

            connection.Listener.OnPing += new PingEventHandler(OnPing);
            connection.Listener.OnPing += new PingEventHandler((a) => ResetHeartbeatMonitor());
            connection.Listener.OnJoin += new JoinEventHandler(onJoin);
            connection.Listener.OnJoin += new JoinEventHandler((a, b) => ResetHeartbeatMonitor());
            connection.Listener.OnPart += new PartEventHandler(OnPart);
            connection.Listener.OnPart += new PartEventHandler((a, b, c) => ResetHeartbeatMonitor());
            connection.Listener.OnQuit += new QuitEventHandler(OnQuit);
            connection.Listener.OnInfo += new InfoEventHandler(OnInfo);
            connection.Listener.OnInfo += new InfoEventHandler((a, b) => ResetHeartbeatMonitor());

            heartbeatMonitor = new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
            heartbeatMonitor.AutoReset = true;
            heartbeatMonitor.Elapsed += HeartbeatMonitor_Elapsed;
            heartbeatMonitor.Start();

            reconnectTimer = new Timer();
            reconnectTimer.AutoReset = false;
            reconnectTimer.Elapsed += ReconnectTimer_Elapsed;

            reconnectBackoff = new ExponentialBackoff();
        }
示例#7
0
 /// <summary>
 /// Prepare a connection to an IRC server but do not open it. This sets the text Encoding to Default.
 /// </summary>
 /// <param name="args">The set of information need to connect to an IRC server</param>
 public Connection(ConnectionArgs args)
 {
     propertiesRegex   = new Regex("([A-Z]+)=([^\\s]+)", RegexOptions.Compiled | RegexOptions.Singleline);
     registered        = false;
     connected         = false;
     handleNickFailure = true;
     connectionArgs    = args;
     sender            = new Sender(this);
     listener          = new Listener( );
     RegisterDelegates();
     timeLastSent = DateTime.UtcNow;
     TextEncoding = Encoding.Default;
 }
示例#8
0
        public ForgeBot(string channel, string opchannel, string nick, string server)
        {
            if (!File.Exists("Sharkbite.Thresher.dll"))
            {
                Server.irc = false;
                Server.s.Log("[IRC] The IRC dll was not found!");
                return;
            }
            this.channel = channel.Trim(); this.opchannel = opchannel.Trim(); this.nick = nick.Replace(" ", ""); this.server = server;
            ConnectionArgs con = new ConnectionArgs(nick, server);
            con.Port = Server.ircPort;
            connection = new Connection(con, false, false);
            banCmd = new List<string>();
            if (Server.irc)
            {
                // Regster events for outgoing
                Player.PlayerChat += new Player.OnPlayerChat(Player_PlayerChat);
                Player.PlayerConnect += new Player.OnPlayerConnect(Player_PlayerConnect);
                Player.PlayerDisconnect += new Player.OnPlayerDisconnect(Player_PlayerDisconnect);

                // Regster events for incoming
                connection.Listener.OnNick += new NickEventHandler(Listener_OnNick);
                connection.Listener.OnRegistered += new RegisteredEventHandler(Listener_OnRegistered);
                connection.Listener.OnPublic += new PublicMessageEventHandler(Listener_OnPublic);
                connection.Listener.OnPrivate += new PrivateMessageEventHandler(Listener_OnPrivate);
                connection.Listener.OnError += new ErrorMessageEventHandler(Listener_OnError);
                connection.Listener.OnQuit += new QuitEventHandler(Listener_OnQuit);
                connection.Listener.OnJoin += new JoinEventHandler(Listener_OnJoin);
                connection.Listener.OnPart += new PartEventHandler(Listener_OnPart);
                connection.Listener.OnDisconnected += new DisconnectedEventHandler(Listener_OnDisconnected);

                // Load banned commands list
                if (File.Exists("text/ircbancmd.txt")) // Backwards compatibility
                {
                    using (StreamWriter sw = File.CreateText("text/irccmdblacklist.txt"))
                    {
                        sw.WriteLine("#Here you can put commands that cannot be used from the IRC bot.");
                        sw.WriteLine("#Lines starting with \"#\" are ignored.");
                        foreach (string line in File.ReadAllLines("text/ircbancmd.txt"))
                            sw.WriteLine(line);
                    }
                    File.Delete("text/ircbancmd.txt");
                }
                else
                {
                    if (!File.Exists("text/irccmdblacklist.txt")) File.WriteAllLines("text/irccmdblacklist.txt", new String[] { "#Here you can put commands that cannot be used from the IRC bot.", "#Lines starting with \"#\" are ignored." });
                    foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt"))
                        if (line[0] != '#') banCmd.Add(line);
                }
            }
        }
示例#9
0
文件: Bot.cs 项目: nebez/TwitchBot
        public void Connect(string host, int port, string botnickname, string serverpassword)
        {
            //Create Identd server
            Identd.Start(botnickname);

            //Create connection args
            ircArgs = new ConnectionArgs();
            ircArgs.Hostname = host;
            ircArgs.Port = port;
            ircArgs.ClientName = "TWITCHCLIENT 3"; //yay, twitchclient 3 is out!
            ircArgs.Nick = botnickname;
            ircArgs.RealName = botnickname;
            ircArgs.UserName = botnickname;
            ircArgs.ServerPassword = serverpassword;

            //Create ircConnection
            ircConnection = new Connection(ircArgs, false, false);

            //Setup our irc event handlers
            ircConnection.Listener.OnRegistered += new RegisteredEventHandler(OnRegistered);
            ircConnection.Listener.OnPublic += new PublicMessageEventHandler(OnPublic);
            ircConnection.Listener.OnPrivate += new PrivateMessageEventHandler(OnPrivate);
            ircConnection.Listener.OnChannelModeChange += new ChannelModeChangeEventHandler(OnChannelModeChange);
            ircConnection.Listener.OnError += new ErrorMessageEventHandler(OnError);
            ircConnection.Listener.OnDisconnected += new DisconnectedEventHandler(OnDisconnected);
            ircConnection.Listener.OnAction += new ActionEventHandler(OnAction);

            //Let's try connecting!
            try
            {
                Logger.Log.Write("Connecting to " + host + ":" + port + "...", ConsoleColor.DarkGray);
                ircConnection.Connect();
            }
            catch (Exception e)
            {
                Logger.Log.Write("Error connecting to network, exception: " + e.ToString(), ConsoleColor.Red);
                Identd.Stop();
                return;
            }

            //We made it!
            Logger.Log.Write("Connected to " + host, ConsoleColor.DarkGray);

            //Create our message queue poller
            messageQueue = new Queue<KeyValuePair<Channel, string>>();
            previousMessageTimestamps = new List<int>();
            messageThread = new Thread(new ThreadStart(MessagePoller));
            messageThread.Start();
        }
示例#10
0
 /// <summary>
 /// Prepare a connection to an IRC server but do not open it. This sets the text Encoding to Default.
 /// </summary>
 /// <param name="args">The set of information need to connect to an IRC server</param>
 /// <param name="enableCtcp">True if this Connection should support CTCP.</param>
 /// <param name="enableDcc">True if this Connection should support DCC.</param>
 public Connection(ConnectionArgs args, bool enableCtcp, bool enableDcc)
 {
     propertiesRegex   = new Regex("([A-Z]+)=([^\\s]+)", RegexOptions.Compiled | RegexOptions.Singleline);
     registered        = false;
     connected         = false;
     handleNickFailure = true;
     connectionArgs    = args;
     parsers           = new ArrayList();
     sender            = new Sender(this);
     listener          = new Listener( );
     RegisterDelegates();
     timeLastSent = DateTime.Now;
     EnableCtcp   = enableCtcp;
     EnableDcc    = enableDcc;
     TextEncoding = Encoding.Default;
 }
示例#11
0
 /// <summary>
 /// The USER command is only used at the beginning of Connection to specify
 /// the username, hostname and realname of a new user.
 /// </summary>
 /// <param name="args">The user Connection data</param>
 internal void User(ConnectionArgs args)
 {
     lock (this)
     {
         buffer.Append("USER");
         buffer.Append(SPACE);
         buffer.Append(args.UserName);
         buffer.Append(SPACE);
         buffer.Append(args.ModeMask);
         buffer.Append(SPACE);
         buffer.Append('*');
         buffer.Append(SPACE);
         buffer.Append(':');
         buffer.Append(args.RealName);
         connection.SendCommand(buffer);
     }
 }
示例#12
0
 public void Connect()
 {
     Identd.Start(_settings.Nick);
     var connectionArgs = new ConnectionArgs(_settings.Nick, _settings.Server);
     _connection = new Connection(connectionArgs, DISABLE_CTCP, DISABLE_DCC);
     InitializeEvents();
     try
     {
         Console.WriteLine("* Connecting to {0} as {1}", _settings.Server, _settings.Nick);
         _connection.Connect();
     }
     catch
     {
         Identd.Stop();
         throw;
     }
 }
示例#13
0
文件: MainWindow.cs 项目: ibarra/bot
        protected virtual void OnButton1Clicked(object sender, System.EventArgs e)
        {
            string server, port;

            try{

                server = entryServer.Text;

                if(server != ""){
                    ConnectionArgs args = new ConnectionArgs(BotName, server);
                    connection = new Connection(args,false, false);
                    Identd.Start(BotName);
                    connection.Connect();

                    if(	connection.Connected ){
                        textviewLog.Buffer.Text = "Conectado al irc . ";
                        channel = entryChannel.Text;
                    }

                     //Identd.Stop  ();

                    connection.Listener.OnRegistered += new  RegisteredEventHandler  ( OnRegistered );
                    connection.Listener.OnPublic += new  PublicMessageEventHandler  ( OnPublic );
                    connection.Listener.OnPrivate += new PrivateMessageEventHandler (OnPrivate );
                    connection.Listener.OnJoin += new JoinEventHandler(OnJoin);
                    //connection.Listener.OnQuit += new QuitEventHandler(OnQuit);

                }else{
                    DialogError de = new DialogError();
                    de.Run();
                    de.Destroy();
                }

            }catch(Exception bke){
                Console.WriteLine("Error on Connection " + bke.StackTrace.ToString());
            }
        }
示例#14
0
 private void CreateConnection()
 {
     string server = "sunray.sharkbite.org";
     string nick = "FileClient";
     ConnectionArgs cargs = new ConnectionArgs(nick, server);
     connection = new Connection( cargs, false, true );
 }
示例#15
0
        private void Connect()
        {
            _userInitiatedDisconnect = false;

            ConnectionArgs connectionArgs = new ConnectionArgs()
            {
                Nick = Network.BotNickname,
                RealName = Network.BotRealname,
                UserName = Network.BotUsername,
                Hostname = Network.ServerList[0].Host,
                Port = Network.ServerList[0].Port ?? 6667
            };

            _ircConnection = new Connection(connectionArgs, true, false);
            _ircConnection.OnRawMessageReceived += _ircConnection_OnRawMessageReceived;
            _ircConnection.OnRawMessageSent += _ircConnection_OnRawMessageSent;
            _ircConnection.Listener.OnRegistered += Listener_OnRegistered;
            _ircConnection.Listener.OnPrivateNotice += Listener_OnPrivateNotice;
            _ircConnection.Listener.OnPublic += Listener_OnPublic;
            _ircConnection.Listener.OnPrivate += Listener_OnPrivate;
            _ircConnection.Listener.OnDisconnected += Listener_OnDisconnected;

            _ircConnection.Connect();
        }
示例#16
0
		/// <summary>
		/// User registration consists of 3 commands:
		/// 1. PASS
		/// 2. NICK
		/// 3. USER
		/// Pass will rarely fail but the proposed Nick might already be taken in
		/// which case the client will have to register by manually calling Nick
		/// and User.
		/// </summary>
		internal void RegisterConnection( ConnectionArgs args ) 
		{
			Pass( args.ServerPassword );
			Nick( args.Nick );
			User( args );
		}
示例#17
0
        private void CreateConnection()
        {
            //The hostname of the IRC server
            string server = "sunray.sharkbite.org";

            //The bot's nick on IRC
            string nick = "EchoBot";

            //A ConnectionArgs contains all the info we need to establish
            //our connection with the IRC server and register our bot.
            ConnectionArgs cargs = new ConnectionArgs(nick, server);

            //We want to enable CTCP but not DCC for this bot.
            connection = new Connection( cargs, true, false );

            //CtcpResponder will automatically reply to CTCP queries using
            //either default values or ones you set. You can also set
            //the minimum interval between responses so that the bot
            //cannot be tricked into flooding IRC.
            CtcpResponder autoResponder = new CtcpResponder( connection );
            autoResponder.UserInfoResponse = "A simple but friendly bot.";
            autoResponder.ClientInfoResponse = "EchoBot";
            //The minimum interval is in milliseconds.
            autoResponder.ResponseDelay = 1000;

            //To enable this responder the connection must have
            //its CTCPResponder property set to an instance.
            //It can be turned off later by setting the CTCPResponder
            //property to null;
            connection.CtcpResponder = autoResponder;
        }
示例#18
0
 /// <summary>
 /// Prepare a connection to an IRC server but do not open it.
 /// </summary>
 /// <param name="args">The set of information need to connect to an IRC server</param>
 /// <param name="enableCtcp">True if this Connection should support CTCP.</param>
 /// <param name="enableDcc">True if this Connection should support DCC.</param>
 /// <param name="textEncoding">The text encoding for the incoming stream.</param>
 public Connection(Encoding textEncoding, ConnectionArgs args, bool enableCtcp, bool enableDcc) : this(args, enableCtcp, enableDcc)
 {
     TextEncoding = textEncoding;
 }
示例#19
0
        private void CreateConnection()
        {
            string server = "washington.dc.us.undernet.org";
            string nick = "UltraBot";
            ConnectionArgs cargs = new ConnectionArgs(nick, server);
            connection = new Connection( cargs, false, false );
            //We don't need to enable CTCP because we are using our own
            //custom parser.

            //Let's add a custom parser to this connection.
            CustomParser parser = new CustomParser( connection );
            connection.AddParser( parser );

            //Custom parsers are intended to allow developers to handle messages
            //not already handled by Thresher itself.  For example, XDCC support
            //or some odd DCC type like Voice could be added.
            //There is an event, Connection.OnRawMessageReceived(), which
            //allows developers to receive  unparsed messages from the IRC server.
            //But though this can be used in a manner similar to a custom parser
            //the new parser mechanism is cleaner and more efficient.
        }
示例#20
0
        private void CreateConnection()
        {
            //The hostname of the IRC server
                string server = "sunray.sharkbite.org";

                //The bot's nick on IRC
                string nick = "ChatBot";

                //The nick to chat with
                remote = "Admin";

                ConnectionArgs cargs = new ConnectionArgs(nick, server);
                //Enable DCC
                connection = new Connection( cargs, false, true );
        }
示例#21
0
 /// <summary>
 /// Get the connection args that have been specified by the configuration information
 /// </summary>
 /// <returns>The relevant connection arguments</returns>
 private ConnectionArgs GetConnArgs()
 {
     var cargs = new ConnectionArgs(_botUsername, IrcHost) { Nick = _botUsername, RealName = _botUsername, UserName = _botUsername, ServerPassword = _botPassword };
     return cargs;
 }
示例#22
0
 /// <summary>
 /// Prepare a connection to an IRC server but do not open it.
 /// </summary>
 /// <param name="args">The set of information need to connect to an IRC server</param>
 /// <param name="textEncoding">The text encoding for the incoming stream.</param>
 public Connection(Encoding textEncoding, ConnectionArgs args) : this( args )
 {
     TextEncoding = textEncoding;
 }
示例#23
0
        private void CreateConnection()
        {
            //The hostname of the IRC server. This IRC net
            //supports SSL connections but others may not.
            string server = "ssl.axenet.org";

            //The bot's nick name on IRC
            string nick = "CryptoBot";

            //A ConnectionArgs contains all the info we need to establish
            //our connection with the IRC server and register our bot. We can still
            //use the default constructor but we need to change the
            //port to the port on the server which supports SSL (in this case 6697).
            ConnectionArgs cargs = new ConnectionArgs(nick, server);
            cargs.Port = 6697;

            //When creating a Connection two additional protocols may be
            //enabled: CTCP and DCC. In this example we will disable them
            //both.
            connection = new Connection( cargs, false, false );

            //NOTE
            //We could have created multiple Connections to different IRC servers
            //and each would process messages simultaneously and independently.
            //There is no fixed limit on how many Connection can be opened at one time but
            //it is important to realize that each runs in its own Thread. Also,  separate event
            //handlers are required for each connection, i.e. the
            //same OnRegistered() handler cannot be used for different connection
            //instances.
        }
示例#24
0
文件: Sender.cs 项目: nebez/TwitchBot
		/// <summary>
		/// User registration consists of 3 commands:
		/// 1. PASS
		/// 2. NICK
		/// 3. USER
		/// Pass will rarely fail but the proposed Nick might already be taken in
		/// which case the client will have to register by manually calling Nick
		/// and User.
		/// </summary>
		internal void RegisterConnection( ConnectionArgs args ) 
		{
            //Are we spoofing a client?
            if(args.ClientName != "")
                Client(args.ClientName);
			Pass( args.ServerPassword );
			Nick( args.Nick );
			User( args );
		}
示例#25
0
 private void CreateConnection()
 {
     Identd.Stop();
     string server = "mozilla.se.eu.dal.net";
     string nick = "Will571";
     Identd.Start(nick);
     ConnectionArgs cargs = new ConnectionArgs(nick, server);
     cargs.Port = 6665;
     connection = new Connection(cargs, false, false);
 }
示例#26
0
 /// <summary>
 /// User registration consists of 3 commands:
 /// 1. PASS
 /// 2. NICK
 /// 3. USER
 /// Pass will rarely fail but the proposed Nick might already be taken in
 /// which case the client will have to register by manually calling Nick
 /// and User.
 /// </summary>
 internal void RegisterConnection(ConnectionArgs args)
 {
     Pass(args.ServerPassword);
     Nick(args.Nick);
     User(args);
 }
示例#27
0
文件: Main.cs 项目: zahlio/hugbotty
        // IRC COMMANDS
        private void CreateConnection()
        {
            //The hostname of the IRC server
            string server = serverBox.Text;

            //The bot's nick on IRC
            string nick = usernameBox.Text;
            string password = OAuthBox.Text;

            //Fire up the Ident server for those IRC networks
            //silly enough to use it.
            Identd.Start(nick);

            //A ConnectionArgs contains all the info we need to establish
            //our connection with the IRC server and register our bot.
            //This line uses the simplfied contructor and the default values.
            //With this constructor the Nick, Real Name, and User name are
            //all set to the same value. It will use the default port of 6667 and no server
            //password.
            ConnectionArgs cargs = new ConnectionArgs(nick, server);
            cargs.ServerPassword = password;
            cargs.Port = 6667;

            //When creating a Connection two additional protocols may be
            //enabled: CTCP and DCC. In this example we will disable them
            //both.
            connection = new Connection(cargs, false, false);

            //NOTE
            //We could have created multiple Connections to different IRC servers
            //and each would process messages simultaneously and independently.
            //There is no fixed limit on how many Connection can be opened at one time but
            //it is important to realize that each runs in its own Thread. Also,separate event
            //handlers are required for each connection, i.e. the
            //same OnRegistered () handler cannot be used for different connection
            //instances.
            try
            {
                //Calling Connect() will cause the Connection object to open a
                //socket to the IRC server and to spawn its own thread. In this
                //separate thread it will listen for messages and send them to the
                //Listener for processing.
                connection.Connect();
                Console.WriteLine("Connected.");
                this.Invoke(new Action(() => this.chatMessage.Text += "[SYSTEM] CONNECTED to " + server + ":6667 #" + channelBox.Text + " with " + nick +"\n"));
                this.Invoke(new Action(() => this.chart1.Series["User(s) in chat"].Points.AddXY(DateTime.Now.ToString("H:mm"), 1)));

                this.Invoke(new Action(() => {
                    this.connectButton.Enabled = false;
                    this.infoPanel.Enabled = false;
                    this.topPanel.Enabled = true;
                    this.chatText.Enabled = true;
                    this.chatButton.Enabled = true;
                    EnableTab(this.giveawayPage, true);
                    EnableTab(this.bettingPage, true);
                    EnableTab(this.challengePage, true);
                    EnableTab(this.graphPage, true);
                    EnableTab(this.databasePage, true);
                    currentGiveawayBox.Enabled = false;
                    currentBet.Enabled = false;

                    timer5min = new System.Timers.Timer(1000);
                    timer5min.Elapsed += new ElapsedEventHandler(timerTick);
                    timer5min.Enabled = true; // Enable it
                    nextSync = UnixTimeNow() + (60 * 5); // sync every 5 min
                    nextMin = UnixTimeNow() + 60;
                }));

                //The main thread ends here but the Connection's thread is still alive.
                //We are now in a passive mode waiting for events to arrive.
                connection.Sender.PublicMessage("#" + channelBox.Text, "HugBotty.com is in da house!");

            }
            catch (Exception e)
            {
                Console.WriteLine("Error during connection process.");
                this.Invoke(new Action(() => this.chatMessage.Text += "[SYSTEM] Error during connection process.\n"));
                Console.WriteLine(e);
                Identd.Stop();
            }
        }
示例#28
0
文件: Sender.cs 项目: nebez/TwitchBot
		/// <summary>
		/// The USER command is only used at the beginning of Connection to specify
		/// the username, hostname and realname of a new user.
		/// </summary>
		/// <param name="args">The user Connection data</param>
		internal void User( ConnectionArgs args ) 
		{
			lock( this )
			{
				Buffer.Append("USER");
				Buffer.Append(SPACE);
				Buffer.Append( args.UserName );
				Buffer.Append(SPACE);
				Buffer.Append( args.ModeMask );
				Buffer.Append(SPACE);
				Buffer.Append('*');
				Buffer.Append(SPACE);
				Buffer.Append( args.RealName );
				Connection.SendCommand( Buffer );
			}
		}
示例#29
0
        private void CreateConnection()
        {
            //The hostname of the IRC server
                string server = "sunray.sharkbite.org";

                //The bot's nick on IRC
                string nick = "EchoBot";

                //Fire up the Ident server for those IRC networks
                //silly enough to use it.
                Identd.Start( nick );

                //A ConnectionArgs contains all the info we need to establish
                //our connection with the IRC server and register our bot.
                //This line uses the simplfied contructor and the default values.
                //With this constructor the Nick, Real Name, and User name are
                //all set to the same value. It will use the default port of 6667 and no server
                //password.
                ConnectionArgs cargs = new ConnectionArgs(nick, server);

                //When creating a Connection two additional protocols may be
                //enabled: CTCP and DCC. In this example we will disable them
                //both.
                connection = new Connection( cargs, false, false );

            //NOTE
            //We could have created multiple Connections to different IRC servers
            //and each would process messages simultaneously and independently.
            //There is no fixed limit on how many Connection can be opened at one time but
            //it is important to realize that each runs in its own Thread. Also,  separate event
            //handlers are required for each connection, i.e. the
            //same OnRegistered() handler cannot be used for different connection
            //instances.
        }