コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: MeCommand.cs プロジェクト: thebentern/JabbR
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: MeCommand.cs プロジェクト: mattmhersh/JabbR
        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);
        }
コード例 #6
0
ファイル: NudgeCommand.cs プロジェクト: richross/JabbR
        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));
            }
        }
コード例 #7
0
        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));
            }
        }