コード例 #1
0
ファイル: Program.cs プロジェクト: RosaryMala/Shadowbot
        static void Main(string[] args)
        {
            IRCConfig conf = new IRCConfig();

            conf.name   = "ShadowBot";
            conf.nick   = "ShadowBot";
            conf.port   = 6667;
            conf.server = "irc.darkmyst.org";
            new IRCBot(conf);
            Console.WriteLine("Bot quit/crashed");
            Console.ReadLine();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: RosaryMala/Shadowbot
        public IRCBot(IRCConfig config)
        {
            bool stayConnected = true;

            while (stayConnected)
            {
                this.config = config;
                try
                {
                    IRCConnection = new TcpClient(config.server, config.port);
                }
                catch
                {
                    Console.WriteLine("Connection Error");
                }

                try
                {
                    ns             = IRCConnection.GetStream();
                    ns.ReadTimeout = 10;
                    sr             = new StreamReader(ns);
                    sw             = new StreamWriter(ns);

                    sendData("USER", config.nick + " Japa " + " Japa" + " :" + config.name);
                    sendData("NICK", config.nick);
                    stayConnected = !IRCWork();
                }
                catch
                {
                    Console.WriteLine("Communication error");
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                    if (sw != null)
                    {
                        sw.Close();
                    }
                    if (ns != null)
                    {
                        ns.Close();
                    }
                    if (IRCConnection != null)
                    {
                        IRCConnection.Close();
                    }
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: JapaMala/Shadowbot
        public IRCBot(IRCConfig config)
        {
            bool stayConnected = true;
            while (stayConnected)
            {
                this.config = config;
                try
                {
                    IRCConnection = new TcpClient(config.server, config.port);
                }
                catch
                {
                    Console.WriteLine("Connection Error");
                }

                try
                {
                    ns = IRCConnection.GetStream();
                    ns.ReadTimeout = 10;
                    sr = new StreamReader(ns);
                    sw = new StreamWriter(ns);

                    sendData("USER", config.nick + " Japa " + " Japa" + " :" + config.name);
                    sendData("NICK", config.nick);
                    stayConnected = !IRCWork();
                }
                catch
                {
                    Console.WriteLine("Communication error");
                }
                finally
                {
                    if (sr != null)
                        sr.Close();
                    if (sw != null)
                        sw.Close();
                    if (ns != null)
                        ns.Close();
                    if (IRCConnection != null)
                        IRCConnection.Close();
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: JapaMala/Shadowbot
 static void Main(string[] args)
 {
     IRCConfig conf = new IRCConfig();
     conf.name = "ShadowBot";
     conf.nick = "ShadowBot";
     conf.port = 6667;
     conf.server = "irc.darkmyst.org";
     new IRCBot(conf);
     Console.WriteLine("Bot quit/crashed");
     Console.ReadLine();
 }