本文整理汇总了C#中IUser.GetChannelEntry方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.GetChannelEntry方法的具体用法?C# IUser.GetChannelEntry怎么用?C# IUser.GetChannelEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUser
的用法示例。
在下文中一共展示了IUser.GetChannelEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KickUser
/// <summary>
/// Kicks a user from a channel
/// </summary>
/// <param name="channel"></param>
/// <param name="user"></param>
/// <param name="reason"></param>
/// <returns>TRUE if the user is sucessfully kicked</returns>
public bool KickUser(string channel, IUser user, string reason)
{
if (channel.Length < 2 || channel[0] != '#')
{
throw new InvalidChannelException();
}
if (user == null)
{
throw new ArgumentNullException("user");
}
if (user.IsService)
{
throw new CannotKickServiceException();
}
ChannelEntry currentEntry = User.GetChannelEntry(channel);
if (currentEntry == null)
{
throw new NotOnChannelException();
}
if ((currentEntry.Op == false) && (currentEntry.HalfOp == false))
{
throw new NotAChannelOperatorException();
}
ChannelEntry userEntry = user.GetChannelEntry(channel);
if (userEntry == null)
{
throw new NotOnChannelException();
}
if ((userEntry.HalfOp == true) && (currentEntry.HalfOp == true))
{
throw new NotAChannelOperatorException();
}
var command =
Plugin.Service.CommandFactory.CreateKickUserCommand();
command.From = User;
command.User = user;
command.Channel = channel;
command.Reason = reason;
Plugin.Service.SendCommand(command);
return true;
}