本文整理汇总了C#中JabbR.Commands.CallerContext类的典型用法代码示例。如果您正苦于以下问题:C# CallerContext类的具体用法?C# CallerContext怎么用?C# CallerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallerContext类属于JabbR.Commands命名空间,在下文中一共展示了CallerContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Execute
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();
}
}
开发者ID:Widdershin,项目名称:vox,代码行数:25,代码来源:MentionsCommand.cs
示例2: Execute
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();
}
开发者ID:nonintanon,项目名称:JabbR,代码行数:25,代码来源:RemoveOwnerCommand.cs
示例3: Execute
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();
}
开发者ID:adamralph,项目名称:JabbR,代码行数:26,代码来源:AllowCommand.cs
示例4: Execute
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();
}
开发者ID:v-jli,项目名称:jean0603jabbr,代码行数:26,代码来源:KickCommand.cs
示例5: Execute
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));
}
开发者ID:v-jli,项目名称:jean0603jabbr,代码行数:27,代码来源:InviteCodeCommand.cs
示例6: Execute
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));
}
开发者ID:BrianRosamilia,项目名称:JabbR,代码行数:27,代码来源:InviteCodeCommand.cs
示例7: Execute
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);
}
开发者ID:codeprogression,项目名称:JabbR,代码行数:28,代码来源:JoinCommand.cs
示例8: Execute
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();
}
开发者ID:adamralph,项目名称:JabbR,代码行数:26,代码来源:RemoveOwnerCommand.cs
示例9: Execute
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);
}
开发者ID:adamralph,项目名称:JabbR,代码行数:28,代码来源:PrivateMessageCommand.cs
示例10: Execute
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);
}
开发者ID:adamralph,项目名称:JabbR,代码行数:27,代码来源:InviteCommand.cs
示例11: Execute
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);
}
开发者ID:shimazoe,项目名称:cchat2,代码行数:26,代码来源:InviteCommand.cs
示例12: Execute
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);
}
开发者ID:phillip-haydon,项目名称:JabbR,代码行数:26,代码来源:OpenCommand.cs
示例13: Execute
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();
}
开发者ID:BrianRosamilia,项目名称:JabbR,代码行数:26,代码来源:AllowCommand.cs
示例14: Execute
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);
}
开发者ID:dkouznet3,项目名称:JabbR,代码行数:34,代码来源:PrivateMessageCommand.cs
示例15: Execute
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();
}
开发者ID:jrmcdona,项目名称:JabbR,代码行数:33,代码来源:KickCommand.cs
示例16: Execute
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();
}
开发者ID:jharjadi,项目名称:JabbR,代码行数:25,代码来源:UnAllowCommand.cs
示例17: Execute
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));
}
开发者ID:dkouznet3,项目名称:JabbR,代码行数:8,代码来源:ResetInviteCodeCommand.cs
示例18: Execute
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);
}
开发者ID:shimazoe,项目名称:cchat2,代码行数:9,代码来源:AdminCommand.cs
示例19: Execute
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);
}
开发者ID:BrianRosamilia,项目名称:JabbR,代码行数:9,代码来源:AdminCommand.cs
示例20: Execute
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);
}
开发者ID:yadyn,项目名称:JabbR,代码行数:10,代码来源:XyzzyCommand.cs
注:本文中的JabbR.Commands.CallerContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论