/// <summary> /// Ensures that the given user is on the channel and has mod status. /// If not, sends corresponding error messages to user. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <returns></returns> public static ChatChannel EnsureModerator(IUser user, string channelName) { ChatChannel chatChannel = ChatChannelGroup.RetrieveChannel(user, channelName); if (chatChannel == null) { return((ChatChannel)null); } uint low = user.EntityId.Low; ChannelMember channelMember; if (!chatChannel.Members.TryGetValue(low, out channelMember)) { ChannelHandler.SendNotOnChannelReply((IPacketReceiver)user, channelName); } else { if (channelMember.IsModerator) { return(chatChannel); } ChannelHandler.SendNotModeratorReply((IPacketReceiver)user, channelName); } return((ChatChannel)null); }
/// <summary> /// Retrieve the given two ChannelMembers and the Channel they are on, if they /// are all on the channel. If not, sends corresponding error messages to user. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <param name="targetName"></param> /// <param name="userMember"></param> /// <param name="targetMember"></param> /// <returns></returns> public static ChatChannel EnsurePresence(IUser user, string channelName, string targetName, out ChannelMember userMember, out ChannelMember targetMember) { if (!string.IsNullOrEmpty(targetName)) { ChatChannel chatChannel = ChatChannelGroup.RetrieveChannel(user, channelName); if (chatChannel != null) { uint low = user.EntityId.Low; if (!chatChannel.Members.TryGetValue(low, out userMember)) { ChannelHandler.SendNotOnChannelReply((IPacketReceiver)user, channelName); } else { IUser namedEntity = World.GetNamedEntity(targetName, false) as IUser; if (namedEntity == null || !chatChannel.Members.TryGetValue(namedEntity.EntityId.Low, out targetMember)) { ChannelHandler.SendTargetNotOnChannelReply((IPacketReceiver)user, channelName, targetName); } else if (namedEntity != user) { return(chatChannel); } } } } userMember = (ChannelMember)null; targetMember = (ChannelMember)null; return((ChatChannel)null); }
/// <summary> /// Retrieve the given two ChannelMembers and the Channel they are on, if they /// are all on the channel. If not, sends corresponding error messages to user. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <param name="targetName"></param> /// <param name="userMember"></param> /// <param name="targetMember"></param> /// <returns></returns> public static ChatChannel EnsurePresence(IUser user, string channelName, string targetName, out ChannelMember userMember, out ChannelMember targetMember) { if (!string.IsNullOrEmpty(targetName)) { var chan = ChatChannelGroup.RetrieveChannel(user, channelName); if (chan != null) { var chatterLowId = user.EntityId.Low; if (!chan.Members.TryGetValue(chatterLowId, out userMember)) { ChannelHandler.SendNotOnChannelReply(user, channelName); } else { var targetUser = World.GetNamedEntity(targetName, false) as IUser; if (targetUser == null || !chan.Members.TryGetValue(targetUser.EntityId.Low, out targetMember)) { ChannelHandler.SendTargetNotOnChannelReply(user, channelName, targetName); } else if (targetUser != user) { return(chan); } } } } userMember = null; targetMember = null; return(null); }
/// <summary> /// Ensures that the given user is on the channel and has mod status. /// If not, sends corresponding error messages to user. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <returns></returns> public static ChatChannel EnsureModerator(IUser user, string channelName) { var chan = ChatChannelGroup.RetrieveChannel(user, channelName); if (chan != null) { var chatterLowId = user.EntityId.Low; ChannelMember member; if (!chan.Members.TryGetValue(chatterLowId, out member)) { ChannelHandler.SendNotOnChannelReply(user, channelName); } else { if (!member.IsModerator) { ChannelHandler.SendNotModeratorReply(user, channelName); } else { return(chan); } } return(null); } return(null); }
/// <summary> /// Retrieves the given ChannelMember and the Channel it is on. /// If not, sends corresponding error messages to user and returns null. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <returns></returns> public static ChatChannel EnsurePresence(IUser user, string channelName, out ChannelMember member) { ChatChannel chatChannel = ChatChannelGroup.RetrieveChannel(user, channelName); if (chatChannel != null) { uint low = user.EntityId.Low; if (chatChannel.Members.TryGetValue(low, out member)) { return(chatChannel); } ChannelHandler.SendNotOnChannelReply((IPacketReceiver)user, channelName); return((ChatChannel)null); } member = (ChannelMember)null; return((ChatChannel)null); }
/// <summary> /// Parses any incoming channel messages. /// </summary> /// <param name="type">the type of chat message indicated by the client</param> /// <param name="language">the chat language indicated by the client</param> /// <param name="packet">the actual chat message packet</param> private static void ChannelParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet) { var channel = packet.ReadCString(); var message = packet.ReadCString(); if (RealmCommandHandler.HandleCommand(sender, message, sender.Target as Character)) { return; } var chan = ChatChannelGroup.RetrieveChannel(sender, channel); if (chan == null) { return; } chan.SendMessage(sender, message); }
/// <summary> /// Retrieves the given ChannelMember and the Channel it is on. /// If not, sends corresponding error messages to user and returns null. /// </summary> /// <param name="user"></param> /// <param name="channelName"></param> /// <returns></returns> public static ChatChannel EnsurePresence(IUser user, string channelName, out ChannelMember member) { var chan = ChatChannelGroup.RetrieveChannel(user, channelName); if (chan != null) { var chatterLowId = user.EntityId.Low; if (!chan.Members.TryGetValue(chatterLowId, out member)) { ChannelHandler.SendNotOnChannelReply(user, channelName); } else { return(chan); } return(null); } member = null; return(null); }