2013-04-09 21:19:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2013-04-09 23:24:50 +00:00
|
|
|
|
using ChatSharp.Events;
|
2013-04-09 21:19:48 +00:00
|
|
|
|
|
|
|
|
|
namespace ChatSharp.Handlers
|
|
|
|
|
{
|
|
|
|
|
internal static class MessageHandlers
|
|
|
|
|
{
|
|
|
|
|
public static void RegisterDefaultHandlers()
|
|
|
|
|
{
|
2013-04-09 23:24:50 +00:00
|
|
|
|
// General
|
|
|
|
|
IrcClient.SetHandler("PING", HandlePing);
|
|
|
|
|
IrcClient.SetHandler("NOTICE", HandleNotice);
|
|
|
|
|
IrcClient.SetHandler("PRIVMSG", HandlePrivmsg);
|
|
|
|
|
IrcClient.SetHandler("431", HandleErronousNick);
|
|
|
|
|
IrcClient.SetHandler("432", HandleErronousNick);
|
|
|
|
|
IrcClient.SetHandler("433", HandleErronousNick);
|
|
|
|
|
IrcClient.SetHandler("436", HandleErronousNick);
|
|
|
|
|
|
|
|
|
|
// MOTD Handlers
|
|
|
|
|
IrcClient.SetHandler("375", MOTDHandlers.HandleMOTDStart);
|
|
|
|
|
IrcClient.SetHandler("372", MOTDHandlers.HandleMOTD);
|
|
|
|
|
IrcClient.SetHandler("376", MOTDHandlers.HandleEndOfMOTD);
|
2013-04-09 21:19:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HandlePing(IrcClient client, IrcMessage message)
|
|
|
|
|
{
|
2013-04-09 21:36:07 +00:00
|
|
|
|
client.SendRawMessage("PONG :{0}", message.Payload);
|
2013-04-09 21:19:48 +00:00
|
|
|
|
}
|
2013-04-09 23:24:50 +00:00
|
|
|
|
|
|
|
|
|
public static void HandleNotice(IrcClient client, IrcMessage message)
|
|
|
|
|
{
|
|
|
|
|
client.OnNoticeRecieved(new IrcNoticeEventArgs(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HandlePrivmsg(IrcClient client, IrcMessage message)
|
|
|
|
|
{
|
|
|
|
|
var eventArgs = new PrivateMessageEventArgs(message);
|
|
|
|
|
if (eventArgs.PrivateMessage.ChannelMessage)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HandleErronousNick(IrcClient client, IrcMessage message)
|
|
|
|
|
{
|
|
|
|
|
var eventArgs = new ErronousNickEventArgs(client.User.Nick);
|
|
|
|
|
if (message.Command == "433") // Nick in use
|
|
|
|
|
client.OnNickInUse(eventArgs);
|
|
|
|
|
// else ... TODO
|
|
|
|
|
if (!eventArgs.DoNotHandle)
|
|
|
|
|
client.Nick(eventArgs.NewNick);
|
|
|
|
|
}
|
2013-04-09 21:19:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|