예제 #1
0
 protected void OnCTCPTime(IrcClient sender, IrcEventArgs e)
 {
     if (config.CtcpTime)
     {
         Raw("NOTICE {0} :{1}TIME {2}{1}", Hostmask.ToNick(e.Sender), (char)1, DateTime.Now.ToString("F"));
     }
 }
예제 #2
0
 protected void OnCtcpPing(IrcClient sender, IrcEventArgs e)
 {
     if (config.CtcpPing)
     {
         Raw("NOTICE {0} :{1}PING {2}{1}", Hostmask.ToNick(e.Sender), (char)1, e.Args[0].Split(' ').Last().TrimEnd((char)1));
     }
 }
예제 #3
0
        protected void OnWelcome(IrcClient sender, IrcNumerics numeric, IrcEventArgs e)
        {
            Hostmask = new Hostmask(e.Args[0].Split(' ').Last());
            IPAddress[] addresses = Dns.GetHostAddresses(Hostmask.Host);
            Ip = addresses.First().ToString();

            if (EventConnect != null)
            {
                EventConnect(this, e);
            }
            //Console.WriteLine("Welcome event received");
        }
예제 #4
0
 protected void OnPart(IrcClient sender, IrcEventArgs e)
 {
     if (Hostmask.ToNick(e.Sender) == sender.Nick)
     {
         //I left a channel
         Channels[e.Target].PerformSelfPart(sender, e);
     }
     else
     {
         Channels[e.Target].PerformPart(sender, e);
     }
 }
예제 #5
0
 /// <summary>
 /// Instantiate a new client
 /// </summary>
 /// <param name="config">Configuration object, requires a minimum of server address and nickname</param>
 public IrcClient(IrcConfig config)
 {
     this.config = config;
     Hostmask    = new Hostmask(config.Nick, config.Ident, "not.connected");
     Realname    = config.Realname;
     net         = new Network();
     //Logger = LogManager.GetCurrentClassLogger();
     Channels          = new Dictionary <String, Channel>();
     Users             = new Dictionary <String, User>();
     Connected         = false;
     reconnectAttempts = 0;
     numericHandlers   = new Dictionary <IrcNumerics, List <IrcNumericHandler> >();
 }
예제 #6
0
 protected void OnJoin(IrcClient sender, IrcEventArgs e)
 {
     if (Hostmask.ToNick(e.Sender) == sender.Nick)
     {
         //I want to access Channels here
         //Console.WriteLine("Joined {0}", string.Join(" ", e.Args));
         foreach (string chan in e.Args)
         {
             Channels[chan] = new Channel(this, chan);
             //TODO: Get users
             Channels[chan].PerformSelfJoin(sender, e);
         }
     }
     else
     {
         Channels[e.Args.First()].PerformJoin(this, e);
     }
 }
예제 #7
0
 protected void OnCTCPVersion(IrcClient sender, IrcEventArgs e)
 {
     Raw("NOTICE {0} :{1}VERSION {2}{1}", Hostmask.ToNick(e.Sender), (char)1, config.Version);
 }