public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); if (args.Length == 0) { throw new HubException(LanguageResources.Spoiler_ActionRequired); } var callingRoom = context.Repository.GetRoomByName(callerContext.RoomName); var message = System.Net.WebUtility.HtmlEncode(String.Join(" ", args)); if (message.Contains('[') && message.Contains(']') && message.HasValidBrackets()) { //Case 1: spoilers wrapped with brackets. message = message.Replace("[", "<s>").Replace("]", "</s>"); } else { // Case 2: non-mixed, all hidden message = String.Format(_hiddenFormat, message); } context.NotificationService.SendHtmlMessage(callingUser, callingRoom, message); }
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) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); if (args.Length == 0) { throw new HubException(LanguageResources.Me_ActionRequired); } var content = String.Join(" ", args); context.NotificationService.OnSelfMessage(room, callingUser, content); }
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); room.EnsureOpen(); context.Service.ChangeWelcome(callingUser, room, newWelcome); context.NotificationService.ChangeWelcome(callingUser, room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); if (args.Length == 0) { throw new InvalidOperationException("You what?"); } var content = String.Join(" ", args); context.NotificationService.OnSelfMessage(room, callingUser, content); }
private static void NudgeRoom(CommandContext context, CallerContext callerContext, ChatUser callingUser) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); var betweenNudges = TimeSpan.FromMinutes(1); if (room.LastNudged == null || room.LastNudged < DateTime.Now.Subtract(betweenNudges)) { room.LastNudged = DateTime.Now; context.Repository.CommitChanges(); context.NotificationService.NudgeRoom(room, callingUser); } else { throw new HubException(String.Format(LanguageResources.NudgeRoom_Throttled, betweenNudges.TotalSeconds)); } }
private static void NudgeRoom(CommandContext context, CallerContext callerContext, ChatUser callingUser) { ChatRoom room = context.Repository.VerifyUserRoom(context.Cache, callingUser, callerContext.RoomName); room.EnsureOpen(); var betweenNudges = TimeSpan.FromMinutes(1); if (room.LastNudged == null || room.LastNudged < DateTime.Now.Subtract(betweenNudges)) { room.LastNudged = DateTime.Now; context.Repository.CommitChanges(); context.NotificationService.NudgeRoom(room, callingUser); } else { throw new InvalidOperationException(String.Format("Room can only be nudged once every {0} seconds.", betweenNudges.TotalSeconds)); } }