public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { var mentions = ParseMentions(args); if (mentions.Length == 0) { // List current mentions for user var currentMentions = context.Repository.GetMentionsByUser(callingUser) .Select(m => m.String); context.NotificationService.ChangeMentions(callingUser, currentMentions.ToArray(), false); } else if (mentions.Length > 5) { throw new InvalidOperationException("You are not allowed more than 5 mention strings."); } else { // Update mentions for user UpdateMentions(context, callingUser, mentions); context.NotificationService.ChangeMentions(callingUser, mentions); context.Repository.CommitChanges(); } }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Which owner do you want to remove?"); } string targetUserName = HttpUtility.HtmlDecode(args[0]); ChatUser targetUser = context.Repository.VerifyUser(targetUserName); if (args.Length == 1) { throw new InvalidOperationException("Which room?"); } string roomName = HttpUtility.HtmlDecode(args[1]); ChatRoom targetRoom = context.Repository.VerifyRoom(roomName); context.Service.RemoveOwner(callingUser, targetUser, targetRoom); context.NotificationService.RemoveOwner(targetUser, targetRoom); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who do you want to grant access permissions to?"); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); string roomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new InvalidOperationException("Which room do you want to allow access to?"); } ChatRoom targetRoom = context.Repository.VerifyRoom(roomName, mustBeOpen: false); context.Service.AllowUser(callingUser, targetUser, targetRoom); context.NotificationService.AllowUser(targetUser, targetRoom); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who are you trying to kick?"); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); string targetRoomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new InvalidOperationException("Which room?"); } ChatRoom room = context.Repository.VerifyRoom(targetRoomName); context.Service.KickUser(callingUser, targetUser, room); context.NotificationService.KickUser(targetUser, room); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (String.IsNullOrEmpty(callerContext.RoomName)) { throw new InvalidOperationException("This command cannot be invoked from the Lobby."); } string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new InvalidOperationException("Which room?"); } ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(targetRoom); if (String.IsNullOrEmpty(targetRoom.InviteCode)) { context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode()); } ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName); context.NotificationService.PostNotification(callingRoom, callingUser, String.Format("Invite Code for {0}: {1}", targetRoomName, targetRoom.InviteCode)); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (String.IsNullOrEmpty(callerContext.RoomName)) { throw new HubException(LanguageResources.InvokeFromRoomRequired); } string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new HubException(LanguageResources.InviteCode_RoomRequired); } ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(targetRoom); if (String.IsNullOrEmpty(targetRoom.InviteCode)) { context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode()); } ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName); context.NotificationService.PostNotification(callingRoom, callingUser, String.Format(LanguageResources.InviteCode_Success, targetRoomName, targetRoom.InviteCode)); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Join which room?"); } // Extract arguments string roomName = args[0]; string inviteCode = null; if (args.Length > 1) { inviteCode = args[1]; } // Locate the room, does NOT have to be open ChatRoom room = context.Repository.VerifyRoom(roomName, mustBeOpen: false); if (!context.Repository.IsUserInRoom(context.Cache, callingUser, room)) { // Join the room context.Service.JoinRoom(callingUser, room, inviteCode); context.Repository.CommitChanges(); } context.NotificationService.JoinRoom(callingUser, room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Which owner do you want to remove?"); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); string roomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new InvalidOperationException("Which room do you want to remove the owner from?"); } ChatRoom targetRoom = context.Repository.VerifyRoom(roomName); context.Service.RemoveOwner(callingUser, targetUser, targetRoom); context.NotificationService.RemoveOwner(targetUser, targetRoom); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (context.Repository.Users.Count() == 1) { throw new InvalidOperationException("You're the only person in here..."); } if (args.Length == 0 || String.IsNullOrWhiteSpace(args[0])) { throw new InvalidOperationException("Who do you want to send a private message to?"); } var toUserName = args[0]; ChatUser toUser = context.Repository.VerifyUser(toUserName); if (toUser == callingUser) { throw new InvalidOperationException("You can't private message yourself!"); } string messageText = String.Join(" ", args.Skip(1)).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException(String.Format("What do you want to say to '{0}'?", toUser.Name)); } context.NotificationService.SendPrivateMessage(callingUser, toUser, messageText); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who do you want to invite?"); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); if (targetUser == callingUser) { throw new InvalidOperationException("You can't invite yourself!"); } string roomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new InvalidOperationException("Which room do you want to invite them to?"); } ChatRoom targetRoom = context.Repository.VerifyRoom(roomName, mustBeOpen: false); context.NotificationService.Invite(callingUser, targetUser, targetRoom); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who do you want to invite?"); } string targetUserName = HttpUtility.HtmlDecode(args[0]); ChatUser targetUser = context.Repository.VerifyUser(targetUserName); if (targetUser == callingUser) { throw new InvalidOperationException("You can't invite yourself!"); } if (args.Length == 1) { throw new InvalidOperationException("Invite them to which room?"); } string roomName = HttpUtility.HtmlDecode(args[1]); ChatRoom targetRoom = context.Repository.VerifyRoom(roomName); context.NotificationService.Invite(callingUser, targetUser, targetRoom); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Which room do you want to open?"); } string roomName = args[0]; ChatRoom room = context.Repository.VerifyRoom(roomName, mustBeOpen: false); context.Service.OpenRoom(callingUser, room); // join the room, unless already in the room if (!room.Users.Contains(callingUser)) { context.Service.JoinRoom(callingUser, room, inviteCode: null); context.Repository.CommitChanges(); context.NotificationService.JoinRoom(callingUser, room); } var users = room.Users.ToList(); context.NotificationService.UnCloseRoom(users, room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new HubException(LanguageResources.Allow_UserRequired); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); string roomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new HubException(LanguageResources.Allow_RoomRequired); } ChatRoom targetRoom = context.Repository.VerifyRoom(roomName, mustBeOpen: false); context.Service.AllowUser(callingUser, targetUser, targetRoom); context.NotificationService.AllowUser(targetUser, targetRoom); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (context.Repository.Users.Count() == 1) { throw new InvalidOperationException("You're the only person in here..."); } if (args.Length == 0 || String.IsNullOrWhiteSpace(args[0])) { throw new InvalidOperationException("Who are you trying send a private message to?"); } var toUserName = HttpUtility.HtmlDecode(args[0]); ChatUser toUser = context.Repository.VerifyUser(toUserName); if (toUser == callingUser) { throw new InvalidOperationException("You can't private message yourself!"); } string messageText = String.Join(" ", args.Skip(1)).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException(String.Format("What did you want to say to '{0}'?", toUser.Name)); } HashSet<string> urls; var transform = new TextTransform(context.Repository); messageText = transform.Parse(messageText); messageText = TextTransform.TransformAndExtractUrls(messageText, out urls); context.NotificationService.SendPrivateMessage(callingUser, toUser, messageText); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new HubException(LanguageResources.Kick_UserRequired); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); string targetRoomName = args.Length > 1 ? args[1] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new HubException(LanguageResources.Kick_RoomRequired); } ChatRoom room = context.Repository.VerifyRoom(targetRoomName); context.Service.KickUser(callingUser, targetUser, room); // try to extract the reason string reason = null; if (args.Length > 2) { reason = String.Join(" ", args.Skip(2)).Trim(); } context.NotificationService.KickUser(targetUser, room, callingUser, reason); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Which user to you want to revoke persmissions from?"); } string targetUserName = args[0]; ChatUser targetUser = context.Repository.VerifyUser(targetUserName); if (args.Length == 1) { throw new InvalidOperationException("Which room?"); } string roomName = args[1]; ChatRoom targetRoom = context.Repository.VerifyRoom(roomName); context.Service.UnallowUser(callingUser, targetUser, targetRoom); context.NotificationService.UnallowUser(targetUser, targetRoom); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); context.Service.SetInviteCode(callingUser, room, RandomUtils.NextInviteCode()); context.NotificationService.PostNotification(room, callingUser, String.Format("Invite Code for this room: {0}", room.InviteCode)); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (!callingUser.IsAdmin) { throw new InvalidOperationException("You are not an admin."); } ExecuteAdminOperation(context, callerContext, callingUser, args); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (!callingUser.IsAdmin) { throw new HubException(LanguageResources.AdminRequired); } ExecuteAdminOperation(context, callerContext, callingUser, args); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); var content = String.Join(" ", args); context.NotificationService.OnXyzzy(room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { NudgeRoom(context, callerContext, callingUser); } else { NudgeUser(context, callingUser, args); } }
public override void ExecuteAdminOperation(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException("What message do you want to broadcast?"); } context.NotificationService.BroadcastMessage(callingUser, messageText); }
public override void ExecuteAdminOperation(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new HubException(LanguageResources.Broadcast_MessageRequired); } context.NotificationService.BroadcastMessage(callingUser, messageText); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string newWelcome = String.Join(" ", args).Trim(); ChatService.ValidateWelcome(newWelcome); newWelcome = String.IsNullOrWhiteSpace(newWelcome) ? null : newWelcome; ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); context.Service.ChangeWelcome(callingUser, room, newWelcome); context.NotificationService.ChangeWelcome(callingUser, room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new HubException(LanguageResources.Where_UserRequired); } string targetUserName = args[0]; ChatUser user = context.Repository.VerifyUser(targetUserName); context.NotificationService.ListRooms(user); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Who are you trying to locate?"); } string targetUserName = args[0]; ChatUser user = context.Repository.VerifyUser(targetUserName); context.NotificationService.ListRooms(user); }
public override void Execute(CommandContext context, CallerContext callerContext, Models.ChatUser callingUser, string[] args) { var userMentions = context.Repository.GetMentionsByUser(callingUser).ToList(); foreach (var m in userMentions) { context.Repository.Remove(m); } context.NotificationService.ChangeMentions(callingUser, null); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string message = String.Join(" ", args).Trim(); ChatService.ValidateNote(message); callingUser.AfkNote = String.IsNullOrWhiteSpace(message) ? null : message; callingUser.IsAfk = true; context.NotificationService.ChangeNote(callingUser); context.Repository.CommitChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); if (args.Length == 0) { throw new InvalidOperationException("You what?"); } var content = String.Join(" ", args); context.NotificationService.OnSelfMessage(room, callingUser, content); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (args.Length == 0) { throw new InvalidOperationException("Which room do you want to lock?"); } string roomName = args[0]; ChatRoom room = context.Repository.VerifyRoom(roomName); context.Service.LockRoom(callingUser, room); context.NotificationService.LockRoom(callingUser, room); }