本文整理汇总了C#中IUser.IsOnChannel方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.IsOnChannel方法的具体用法?C# IUser.IsOnChannel怎么用?C# IUser.IsOnChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUser
的用法示例。
在下文中一共展示了IUser.IsOnChannel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveUser
/// <summary>
/// Removes a user from the server
/// </summary>
/// <param name="user"></param>
/// <returns>TRUE if the user is succesfully removed</returns>
public bool RemoveUser(IUser user)
{
lock (lockObject)
{
if (!users.Remove(user.Numeric))
{
return false;
}
foreach (var pair in ChannelEntries.ToArray())
{
if (user.IsOnChannel(pair.Key.Name))
{
var list = pair.Value as List<ChannelEntry>;
for (int i = 0; i < list.Count; i++)
{
if (list[i].User == user)
{
(user as User).OnRemoveFromChannel(pair.Key);
list.RemoveAt(i);
break;
}
}
(pair.Key as Channel).RemoveInvitation(user);
if (list.Count < 1)
{
ChannelEntries.Remove(pair.Key);
channels.Remove(pair.Key.Name);
}
}
}
return true;
}
}
示例2: InviteUserToChannel
/// <summary>
/// Invites a user to a channel
/// </summary>
/// <param name="channel"></param>
/// <param name="user"></param>
/// <returns></returns>
public bool InviteUserToChannel(string channel, IUser user)
{
if (channel.Length < 2 || channel[0] != '#')
{
throw new InvalidChannelException();
}
if (user == null)
{
throw new ArgumentNullException("user");
}
ChannelEntry currentEntry = User.GetChannelEntry(channel);
if (currentEntry == null)
{
throw new NotOnChannelException();
}
if ((currentEntry.Op == false) && (currentEntry.HalfOp == false))
{
throw new NotAChannelOperatorException();
}
if (user.IsOnChannel(channel))
{
throw new UserAlreadyOnChannelException();
}
var command =
Plugin.Service.CommandFactory.CreateInviteUserCommand();
command.From = User;
command.User = user;
command.Channel = currentEntry.Channel;
Plugin.Service.SendCommand(command);
return true;
}
示例3: AddUser
/// <summary>
/// Adds a user to the channel
/// </summary>
/// <param name="user"></param>
/// <param name="op"></param>
/// <param name="voice"></param>
/// <param name="halfop"></param>
/// <returns>TRUE if the user is successfully added</returns>
public bool AddUser(IUser user, bool op, bool voice, bool halfop)
{
lock (lockObject)
{
if (user.IsOnChannel(Name))
{
return false;
}
ChannelEntry entry = new ChannelEntry(this, user);
entry.Op = op;
entry.Voice = voice;
entry.HalfOp = halfop;
var list = user.Server.ChannelEntries[this] as List<ChannelEntry>;
list.Add(entry);
(user as User).OnAddToChannel(entry);
if (Service.BurstCompleted)
{
RemoveInvitation(user);
}
return true;
}
}