public UserPerChannelInfo(UserInfo userInfo, ChannelInfo channelInfo) : base(userInfo.IrcDaemon) { this.userInfo = userInfo; this.channelInfo = channelInfo; modes = new RankList(userInfo.IrcDaemon); }
public KickArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, UserInfo user, string message) : base(sender, receiver, "KICK") { this.channel = channel; this.user = user; this.message = message; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (onlyOnce) { return true; } onlyOnce = true; if (command is Join) { user.IrcDaemon.Commands.Send(new NoticeArgument(user, user, channel.Name, "This channel automatically translates your messages, use the LANGUAGE command to set your preferred language")); } if (!channel.Modes.HandleEvent(command, channel, user, args)) { onlyOnce = false; return false; } if (command is PrivateMessage || command is Notice) { var translateDelegate = new GoogleTranslate.TranslateMultipleDelegate(translator.TranslateText); translateDelegate.BeginInvoke(args[1], channel.Users.Select(u => u.Languages.First()).Distinct(), TranslateCallBack, Tuple.Create(channel, user, command)); onlyOnce = false; return false; } onlyOnce = false; return true; }
public UserPerChannelInfo(UserInfo userInfo, ChannelInfo channelInfo) : base(userInfo.IrcDaemon) { UserInfo = userInfo; ChannelInfo = channelInfo; Modes = new RankList(userInfo.IrcDaemon); }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { if (!user.Invited.Contains(channel)) { user.IrcDaemon.Replies.SendInviteOnlyChannel(user, channel); return false; } user.Invited.Remove(channel); } if (command is Invite) { UserPerChannelInfo upci; if (channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci)) { if (upci.Modes.Level < 30) { channel.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); return false; } } else { channel.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); return false; } } return true; }
public void SendList(UserInfo info, ChannelInfo chan) { foreach (var invite in _inviteExceptionList) { info.IrcDaemon.Replies.SendInviteList(info, chan, invite); } info.IrcDaemon.Replies.SendEndOfInviteList(info, chan); }
public void SendList(UserInfo info, ChannelInfo chan) { foreach (var banExcpetion in _banExceptionList) { info.IrcDaemon.Replies.SendExceptionList(info, chan, banExcpetion); } info.IrcDaemon.Replies.SendEndOfExceptionList(info, chan); }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is List) { // TODO } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { if (!channel.UserPerChannelInfos.ContainsKey(user.Nick)) { user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); return false; } } return true; }
protected override void PrivateHandle(UserInfo info, List<string> args) { if (args[0] == "0") { PartAll(info); return; } foreach (var channel in from temp in GetSubArgument(args[0]) where info.UserPerChannelInfos.All(upci => upci.ChannelInfo.Name != temp) select temp) { ChannelInfo chan; if (IrcDaemon.Channels.ContainsKey(channel)) { chan = IrcDaemon.Channels[channel]; if (!chan.Modes.HandleEvent(this, chan, info, args)) { continue; } } else { if (IrcDaemon.ValidChannel(channel)) { chan = new ChannelInfo(channel, IrcDaemon); IrcDaemon.Channels.Add(chan.Name, chan); } else { IrcDaemon.Replies.SendBadChannelMask(info, channel); return; } } var chanuser = new UserPerChannelInfo(info, chan); // ToDo: this probably should get delegated to the Channel Type specific "NormalChannel" class, because it depends on the channel type. if (!chan.Users.Any()) { chanuser.Modes.Add(IrcDaemon.ModeFactory.GetChannelRank('o')); } chan.UserPerChannelInfos.Add(info.Nick, chanuser); info.UserPerChannelInfos.Add(chanuser); Send(new JoinArgument(info, chan, chan)); SendTopic(info, chan); IrcDaemon.Replies.SendNamesReply(chanuser.UserInfo, chan); IrcDaemon.Replies.SendEndOfNamesReply(info, chan); } }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { UserPerChannelInfo upci; if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci) || upci.Modes.Level < 10) { user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { if (_limit <= channel.UserPerChannelInfos.Count) { user.IrcDaemon.Replies.SendChannelIsFull(user, channel); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { var keys = args.Count > 1 ? (IEnumerable<string>)CommandBase.GetSubArgument(args[1]) : new List<string>(); if (keys.All(k => k != _key)) { user.IrcDaemon.Replies.SendBadChannelKey(user, channel); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is PrivateMessage || command is Notice) { if (args[1].Any(c => c == IrcConstants.IrcColor)) { channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Color is not permitted in this channel"); return false; } if (args[1].Any(c => c == IrcConstants.IrcBold || c == IrcConstants.IrcNormal || c == IrcConstants.IrcUnderline || c == IrcConstants.IrcReverse)) { channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Control codes (bold/underline/reverse) are not permitted in this channel"); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Topic) { UserPerChannelInfo upci; if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out upci)) { user.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); return false; } if (upci.Modes.Level < 30) { user.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); return false; } } return true; }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { if (command is Join) { if (_banList.Select(ban => new WildCard(ban, WildcardMatch.Exact)).Any(usermask => usermask.IsMatch(user.Usermask))) { user.IrcDaemon.Replies.SendBannedFromChannel(user, channel); return false; } } if (command is PrivateMessage || command is Notice) { if (_banList.Select(ban => new WildCard(ban, WildcardMatch.Exact)).Any(usermask => usermask.IsMatch(user.Usermask))) { user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "You are banned from the Channel"); return false; } } return true; }
public TopicArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string newTopic) : base(sender, receiver, "TOPIC") { Channel = channel; NewTopic = newTopic; }
/// <summary> /// Reply Code 366 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> public void SendEndOfNamesReply(UserInfo info, ChannelInfo chan) { BuildMessageHeader(info, ReplyCode.EndOfNames); response.Append(" "); response.Append(chan.Name); response.Append(" :End of NAMES list"); info.WriteLine(response); }
/// <summary> /// Reply Code 346 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> /// <param name="mask"></param> public void SendInviteList(UserInfo info, ChannelInfo chan, string mask) { BuildMessageHeader(info, ReplyCode.InviteList); response.Append(" "); response.Append(chan.Name); response.Append(" "); response.Append(mask); info.WriteLine(response); }
/// <summary> /// Reply Code 473 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> public void SendInviteOnlyChannel(UserInfo info, ChannelInfo chan) { BuildMessageHeader(info, ReplyCode.ErrorInviteOnlyChannel); response.Append(" "); response.Append(chan.Name); response.Append(" :Cannot join channel (+i)"); info.WriteLine(response); }
public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List<string> args) { // Handling JOIN is done in the ModeBan class return true; }
/// <summary> /// Reply Code 322 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> public void SendListItem(UserInfo info, ChannelInfo chan) { BuildMessageHeader(info, ReplyCode.List); response.Append(" "); response.Append(chan.Name); response.Append(" "); response.Append(chan.UserPerChannelInfos.Count); response.Append(" :"); response.Append(chan.Topic); info.WriteLine(response); }
/// <summary> /// Reply Code 353 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> public void SendNamesReply(UserInfo info, ChannelInfo chan) { BuildMessageHeader(info, ReplyCode.NamesReply); response.Append(" "); response.Append(chan.NamesPrefix); response.Append(" "); response.Append(chan.Name); response.Append(" :"); SendSplitted(response.ToString(), info, chan.UserPerChannelInfos.Values.Select(upci => upci.Modes.NickPrefix + upci.UserInfo.Nick), null); }
/// <summary> /// Reply Code 477 /// </summary> /// <param name="info"></param> /// <param name="chan"></param> public void SendNoChannelModes(UserInfo info, ChannelInfo chan) { BuildMessageHeader(info, ReplyCode.ErrorNoChannelModes); response.Append(" "); response.Append(chan.Name); response.Append(" :Channel doesn't support modes"); info.WriteLine(response); }
private void SendTopic(UserInfo info, ChannelInfo chan) { if (string.IsNullOrEmpty(chan.Topic)) { IrcDaemon.Replies.SendNoTopicReply(info, chan); } else { IrcDaemon.Replies.SendTopicReply(info, chan); } }
public JoinArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel) : base(sender, receiver, "JOIN") { Channel = channel; }
public InviteArgument(UserInfo sender, InfoBase receiver, UserInfo invited, ChannelInfo channel) : base(sender, receiver, "INVITE") { this.invited = invited; this.channel = channel; }
public void SendList(UserInfo info, ChannelInfo chan) { foreach (var ban in _banList) { info.IrcDaemon.Replies.SendBanList(info, chan, ban); } info.IrcDaemon.Replies.SendEndOfBanList(info, chan); }
public KnockArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message) : base(sender, receiver, "KNOCK") { this.channel = channel; this.message = message; }
public PartArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message) : base(sender, receiver, "PART") { Channel = channel; Message = message; }