Пример #1
0
        public static void HandleJoin(IrcClient client, IrcMessage message)
        {
            var user    = client.Users.GetOrAdd(message.Prefix);
            var channel = client.Channels.GetOrAdd(message.Parameters[0]);

            if (channel != null)
            {
                if (!user.Channels.Contains(channel))
                {
                    client.CompleteNamedEvent("channel_" + channel.Name);
                    user.Channels.Add(channel);
                }

                // account-notify capability
                if (client.Capabilities.IsEnabled("account-notify"))
                {
                    client.Who(user.Nick, WhoxFlag.None, WhoxField.Nick | WhoxField.AccountName).AsTask().ContinueWith((task, state) => {
                        var userFromState = (IrcUser)state;
                        var whoQuery      = task.Result;
                        if (whoQuery.Count == 1)
                        {
                            userFromState.Account = whoQuery[0].User.Account;
                        }
                    }, user, TaskContinuationOptions.OnlyOnRanToCompletion);
                }

                client.OnUserJoinedChannel(new ChannelUserEventArgs(channel, user));
            }
        }