secret
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
static void Client_Connected(object sender, EventArgs e)
{
Server server = GetServerFromSender(sender);
server.Client.LocalUser.JoinedChannel += new EventHandler<IrcChannelEventArgs>(LocalUser_JoinedChannel);
server.Client.LocalUser.NoticeReceived += new EventHandler<IrcMessageEventArgs>(LocalUser_NoticeReceived);
server.Client.ProtocolError += new EventHandler<IrcProtocolErrorEventArgs>(Client_ProtocolError);
server.Client.Disconnected += new EventHandler<EventArgs>(Client_Disconnected);
server.Client.PongReceived += new EventHandler<IrcPingOrPongReceivedEventArgs>(Client_PongReceived);
server.Client.PingReceived += new EventHandler<IrcPingOrPongReceivedEventArgs>(Client_PingReceived);
server.Client.LocalUser.ModesChanged += new EventHandler<EventArgs>(LocalUser_ModesChanged);
server.Client.Channels.Join(server.Channels.ToArray());
if (server.Password != null)
server.Client.LocalUser.SendMessage("NickServ", "identify " + server.Password);
 
server.Client.LocalUser.MessageReceived += new EventHandler<IrcMessageEventArgs>(LocalUser_MessageReceived);
 
Timer timer = new Timer(new TimerCallback((object o) =>
{
Console.WriteLine("-->PING");
server.Client.Ping("adams.freenode.net");
}), null, 10000, 10000);
}
 
static void LocalUser_ModesChanged(object sender, EventArgs e)
{
Console.WriteLine("Mode has changed.");
}
 
static void Client_PingReceived(object sender, IrcPingOrPongReceivedEventArgs e)
{
Console.WriteLine("<--PING");
}
 
static void Client_PongReceived(object sender, IrcPingOrPongReceivedEventArgs e)
{
Console.WriteLine("<--PONG");
}
 
static void Client_Disconnected(object sender, EventArgs e)
{
Console.WriteLine("DISCONNECTED");
}
 
static void Client_ProtocolError(object sender, IrcProtocolErrorEventArgs e)
{
Console.WriteLine("ERROR: " + e.Code.ToString() + ": " + e.Message);
}
 
static void LocalUser_NoticeReceived(object sender, IrcMessageEventArgs e)
{
Console.WriteLine("-" + e.Source + "-: " + e.Text);
}
 
static void LocalUser_JoinedChannel(object sender, IrcChannelEventArgs e)
{
e.Channel.MessageReceived += new EventHandler<IrcMessageEventArgs>(Channel_MessageReceived);
e.Channel.ModesChanged += new EventHandler<EventArgs>(Channel_ModesChanged);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.