Esempio n. 1
0
        public override bool Equals(object obj)
        {
            IrcBotSettings other = obj as IrcBotSettings;

            if (other == null)
            {
                return(false);
            }
            return(this.Server == other.Server && this.Port == other.Port && this.Nick == other.Nick);
        }
Esempio n. 2
0
 public static IrcBot GetBot(IrcBotSettings settings)
 {
     IrcBot bot;
     lock (bots) {
         if (!bots.TryGetValue(settings, out bot)) {
             bot = new IrcBot(settings);
             bots[settings] = bot;
         }
     }
     return bot;
 }
        public static IrcBot GetBot(IrcBotSettings settings)
        {
            IrcBot bot;

            lock (bots) {
                if (!bots.TryGetValue(settings, out bot))
                {
                    bot            = new IrcBot(settings);
                    bots[settings] = bot;
                }
            }
            return(bot);
        }
Esempio n. 4
0
        private IrcBot(IrcBotSettings settings)
        {
            this.settings = settings;
            client.SendDelay = 750;
            client.OnDisconnected += new EventHandler(client_OnDisconnected);
            client.OnQueryMessage += new IrcEventHandler(client_OnQueryMessage);
            client.OnChannelMessage += new IrcEventHandler(client_OnChannelMessage);
            client.Encoding = new UTF8Encoding(false);

            client.Connect(settings.Server, settings.Port);
            client.Login(settings.Nick, settings.RealName);

            Thread t = new Thread(new ThreadStart(ListenThread));
            t.IsBackground = true;
            t.Start();
        }
        private IrcBot(IrcBotSettings settings)
        {
            this.settings            = settings;
            client.SendDelay         = 750;
            client.OnDisconnected   += new EventHandler(client_OnDisconnected);
            client.OnQueryMessage   += new IrcEventHandler(client_OnQueryMessage);
            client.OnChannelMessage += new IrcEventHandler(client_OnChannelMessage);
            client.Encoding          = new UTF8Encoding(false);

            client.Connect(settings.Server, settings.Port);
            client.Login(settings.Nick, settings.RealName);

            Thread t = new Thread(new ThreadStart(ListenThread));

            t.IsBackground = true;
            t.Start();
        }
 void SendIrcMessage(string message)
 {
     Console.WriteLine(message);
     try {
         IrcBotSettings settings = new IrcBotSettings(
             this.Server, this.Port,
             this.Nick ?? "ccnetbot",
             this.RealName ?? "CCnet IRC Publisher");
         IrcBot   bot      = IrcBot.GetBot(settings);
         string[] channels = this.Room.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
         foreach (string channel in channels)
         {
             bot.SendMessage(channel, message);
         }
     } catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
 }
 void SendIrcMessage(string message)
 {
     Console.WriteLine(message);
     try {
         IrcBotSettings settings = new IrcBotSettings(
             this.Server, this.Port,
             this.Nick ?? "ccnetbot",
             this.RealName ?? "CCnet IRC Publisher");
         IrcBot bot = IrcBot.GetBot(settings);
         string[] channels = this.Room.Split(new char[] { ',', ';'}, StringSplitOptions.RemoveEmptyEntries);
         foreach (string channel in channels) {
             bot.SendMessage(channel, message);
         }
     } catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
 }