本文整理汇总了C#中IrcMessage类的典型用法代码示例。如果您正苦于以下问题:C# IrcMessage类的具体用法?C# IrcMessage怎么用?C# IrcMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IrcMessage类属于命名空间,在下文中一共展示了IrcMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessMessageEndOfStats
protected internal void ProcessMessageEndOfStats(IrcMessage message)
{
Debug.Assert(message.Parameters[0] == localUser.NickName);
OnServerStatsReceived(new IrcServerStatsReceivedEventArgs(listedStatsEntries));
listedStatsEntries = new List<IrcServerStatisticalEntry>();
}
示例2: HandleWhoIsEnd
public static void HandleWhoIsEnd(IrcClient client, IrcMessage message)
{
var request = client.RequestManager.DequeueOperation("WHOIS " + message.Parameters[1]);
if(request.Callback != null)
request.Callback(request);
client.OnWhoIsReceived(new Events.WhoIsReceivedEventArgs((WhoIs)request.State));
}
示例3: Run
public override void Run(IIrcUser client, IrcMessage message)
{
IrcChannel[] channels;
if (message.Params.Length == 0)
{
channels = client.IrcServer.Channels.ToArray();
}
else
{
string[] channelList = message.Params[0].ToLower().Split(',');
channels = client.IrcServer.Channels.Where(channel =>
channelList.Contains(channel.Name.Replace(",", "").ToLower())
).ToArray();
}
channels.ForEach(channel =>
{
client.Write(new IrcNumericResponce
{
NumericId = IrcNumericResponceId.RPL_NAMEREPLY,
Extra = "= " + channel.Name,
Message = string.Join(" ",
channel.Users
.Where(user => !user.Mode.IsInvisible || channel.Users.Contains(client) || client.Mode.IsOperator)
.Select(user => string.Format("{0}{1}", user.ChannelModes[channel].NickPrefix, user.Nick)))
});
});
client.Write(new IrcNumericResponce
{
NumericId = IrcNumericResponceId.RPL_ENDOFNAMES,
Extra = client.Nick,
Message = "End of names"
});
}
示例4: IrcMsg_ToStringNoPrefixNoArgs
public void IrcMsg_ToStringNoPrefixNoArgs()
{
var expected = "PING";
var actual = new IrcMessage("PING", "");
Assert.AreEqual(expected, actual.ToString());
}
示例5: Run
public override void Run(IIrcUser client, IrcMessage message)
{
if (message.Params.Length != 1)
{
SendMessage(IrcNumericResponceId.ERR_NONICKNAMEGIVEN, client, "No nickname given");
return;
}
if (!IRC.CheckString(message.Params[0], IRC.NICKNAME))
{
SendMessage(IrcNumericResponceId.ERR_ERRONEUSNICKNAME, client, "Erroneous nickname");
return;
}
if (!client.IrcServer.CheckNick(message.Params[0]))
{
SendMessage(IrcNumericResponceId.ERR_NICKNAMEINUSE, client, "Nickname is already in use");
return;
}
string oldNick = client.Nick;
client.Channels.ForEach(channel => channel.Nick(client, message.Params[0]));
if (!string.IsNullOrEmpty(client.User))
{
Say(client, "NICK", message.Params[0]);
}
client.Nick = message.Params[0];
}
示例6: Run
public override void Run(IIrcUser client, IrcMessage message)
{
if (message.Params.Length != 1)
{
SendMessage(IrcNumericResponceId.ERR_NEEDMOREPARAMS, client, "Not enough parameters");
return;
}
if (IRC.IsChannel(message.Params[0]))
{
IrcChannel channel = client.IrcServer.Channels.Where(ch => ch.Name == message.Params[0]).FirstOrDefault();
if (channel == null)
{
return;
}
channel.Users.ForEach(cli => cli.Write(new IrcNumericResponce()
{
NumericId = IrcNumericResponceId.RPL_WHOREPLY,
Message = cli.UserString
}));
client.Write(new IrcNumericResponce()
{
NumericId = IrcNumericResponceId.RPL_ENDOFWHO,
Message = "End of who"
});
}
}
示例7: IrcMsg_ToStringArgWithSpace
public void IrcMsg_ToStringArgWithSpace()
{
var expected = ":prefix PRIVMSG blabla :string with a lot of spaces";
var actual = new IrcMessage("PRIVMSG", "prefix", "blabla", "string with a lot of spaces");
Assert.AreEqual(expected, actual.ToString());
}
示例8: Run
// Syntax: INVITE <nick> <channel>
public override void Run(IIrcUser client, IrcMessage message)
{
if (message.Params.Length != 2)
{
NeedMoreParamsError(client);
return;
}
if (client.IrcServer.CheckNick(message.Params[0]))
{
NotFoundError(client, false);
return;
}
if (!IRC.IsChannel(message.Params[1]) || !client.IrcServer.ChannelExists(message.Params[1]))
{
NotFoundError(client, true);
return;
}
IrcChannel channel = client.IrcServer.GetChannel(message.Params[1]);
IIrcUser user = client.IrcServer.Clients.Find(cli => cli.Nick == message.Params[0]);
if (!user.ChannelModes.ContainsKey(channel))
{
user.ChannelModes.Add(channel, new IrcChannelUserMode());
}
IrcChannelUserMode mode = user.ChannelModes[channel];
mode.IsInvited = true;
channel.Command(client, "INVITE", user.Nick);
client.Write(new IrcNumericResponce
{
NumericId = IrcNumericResponceId.RPL_INVITING,
To = channel.Name,
Extra = client.Nick,
Message = "invited."
});
}
示例9: HandleGetEmptyTopic
public static void HandleGetEmptyTopic(IrcClient client, IrcMessage message)
{
var channel = client.Channels.GetOrAdd(message.Parameters[1]);
var old = channel._Topic;
channel._Topic = message.Parameters[2];
client.OnChannelTopicReceived(new ChannelTopicEventArgs(channel, old, channel._Topic));
}
示例10: HandleUserListPart
public static void HandleUserListPart(IrcClient client, IrcMessage message)
{
var channel = client.Channels[message.Parameters[2]];
var users = message.Parameters[3].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var nick in users)
{
if (string.IsNullOrWhiteSpace(nick))
continue;
var mode = client.ServerInfo.GetModeForPrefix(nick[0]);
if (mode == null)
{
var user = client.Users.GetOrAdd(nick);
if (!user.Channels.Contains(channel))
user.Channels.Add(channel);
if (!user.ChannelModes.ContainsKey(channel))
user.ChannelModes.Add(channel, null);
else
user.ChannelModes[channel] = null;
}
else
{
var user = client.Users.GetOrAdd(nick.Substring(1));
if (!user.Channels.Contains(channel))
user.Channels.Add(channel);
if (!user.ChannelModes.ContainsKey(channel))
user.ChannelModes.Add(channel, mode.Value);
else
user.ChannelModes[channel] = mode.Value;
}
}
}
示例11: IrcMessenger
public IrcMessenger()
{
var server = Config.Get("Irc.Server");
var nick = Config.Get("Irc.Nick", Config.Get("Name", "gambot"));
var user = Config.Get("Irc.User", nick);
var password = Config.Get("Irc.Password");
var ssl = Config.GetBool("Irc.Ssl");
client = new IrcClient(server, new IrcUser(nick, user, password),
ssl);
client.SetHandler("372", (c, m) => { }); // Ignore MOTD
client.PrivateMessageRecieved += (sender, args) =>
{
if (MessageReceived != null)
{
var message = new IrcMessage(args.PrivateMessage);
MessageReceived(this,
new MessageEventArgs
{
Message = message,
Addressed =
(!args.PrivateMessage
.IsChannelMessage ||
String.Equals(message.To, nick,
StringComparison
.CurrentCultureIgnoreCase))
});
}
};
client.ConnectAsync();
}
示例12: HandleUserListEnd
public static void HandleUserListEnd(IrcClient client, IrcMessage message)
{
var channel = client.Channels[message.Parameters[1]];
client.OnChannelListRecieved(new ChannelEventArgs(channel));
if (client.Settings.ModeOnJoin)
client.GetMode(channel.Name, c => Console.WriteLine(c.Mode));
}
示例13: HandleMOTDNotFound
public static void HandleMOTDNotFound(IrcClient client, IrcMessage message)
{
client.OnMOTDRecieved(new ServerMOTDEventArgs(MOTD));
client.OnConnectionComplete(new EventArgs());
VerifyOurIdentity(client);
}
示例14: HandleMOTD
public static void HandleMOTD(IrcClient client, IrcMessage message)
{
if (message.Parameters.Length != 2)
throw new IrcProtocolException("372 MOTD message is incorrectly formatted.");
var part = message.Parameters[1].Substring(2);
MOTD += part + Environment.NewLine;
client.OnMOTDPartRecieved(new ServerMOTDEventArgs(part));
}
示例15: HandleInviteListPart
public static void HandleInviteListPart(IrcClient client, IrcMessage message)
{
var parameterString = message.RawMessage.Substring(message.RawMessage.IndexOf(' ') + 1);
var parameters = parameterString.Substring(parameterString.IndexOf(' ') + 1).Split(' ');
var request = client.RequestManager.PeekOperation("GETMODE I " + parameters[1]);
var list = (MaskCollection)request.State;
list.Add(new Mask(parameters[2], new IrcUser(parameters[3]), IrcClient.DateTimeFromIrcTime(int.Parse(parameters[4]))));
}