Exemplo n.º 1
0
        private void UpdateSeen(IrcUser ircUser, UserSeenStatus.ActivityType activityType, string activityText, string channel)
        {
            if (UsersSeen.ContainsKey(ircUser.NickName))
            {
                UserSeenStatus userSeenStatus = UsersSeen[ircUser.NickName];

                if (userSeenStatus.SeenEvents.ContainsKey(activityType))
                {
                    userSeenStatus.SeenEvents[activityType].ActivityText = activityText;
                    userSeenStatus.SeenEvents[activityType].TimeSeen     = DateTime.Now;
                    userSeenStatus.SeenEvents[activityType].Channel      = channel;
                }
                else
                {
                    userSeenStatus.SeenEvents.Add(activityType, new Action {
                        ActivityText = activityText, TimeSeen = DateTime.Now, Channel = channel
                    });
                }

                //update hostmask
                userSeenStatus.HostMask = $"{ircUser.NickName}!{ircUser.UserName}@{ircUser.HostName}";
            }
            else
            {
                UsersSeen.Add(ircUser.NickName, new UserSeenStatus());
                UserSeenStatus userSeenStatus = UsersSeen[ircUser.NickName];
                userSeenStatus.HostMask = $"{ircUser.NickName}!{ircUser.UserName}@{ircUser.HostName}";
                userSeenStatus.SeenEvents.Add(activityType, new Action {
                    ActivityText = activityText, TimeSeen = DateTime.Now, Channel = channel
                });
            }

            SaveSeen();
        }
Exemplo n.º 2
0
        private void ProcessChatCommandSeen(IrcClient client, IIrcMessageSource source,
                                            IList <IIrcMessageTarget> targets, string command, IList <string> parameters)
        {
            if (source is IrcUser)
            {
                if (parameters[0].Equals(source.Name, StringComparison.OrdinalIgnoreCase))
                {
                    client.LocalUser.SendMessage(targets, "If you're trying to find yourself, might I suggest long hikes in nature and meditation.");
                }
                else if (parameters[0].Equals(ConfigSettings.NickName, StringComparison.OrdinalIgnoreCase))
                {
                    client.LocalUser.SendMessage(targets, $"I was last seen being asked a stupid question by {source.Name}.");
                }
                else if (UsersSeen.ContainsKey(parameters[0]))
                {
                    UserSeenStatus status          = UsersSeen[parameters[0]];
                    var            mostRecentEvent = status.SeenEvents.OrderBy(kvp => kvp.Value.TimeSeen).Last();// .Values.Select(kvp => kvp).Max(kvp => kvp.TimeSeen);

                    client.LocalUser.SendMessage(targets, $"{parameters[0]} was last seen in {mostRecentEvent.Value.Channel} {mostRecentEvent.Key.ToFriendlyString()}"
                                                 + $" \"{mostRecentEvent.Value.ActivityText}\" on {status.GetActivityTimeString(mostRecentEvent.Key)}");
                }
                else if (parameters[0].Equals("-l", StringComparison.OrdinalIgnoreCase) && UsersSeen.ContainsKey(parameters[1]))
                {
                    UserSeenStatus status      = UsersSeen[parameters[1]];
                    string         action_time = status.GetActivityTimeString(UserSeenStatus.ActivityType.Action);
                    string         quit_time   = status.GetActivityTimeString(UserSeenStatus.ActivityType.Part);
                    string         join_time   = status.GetActivityTimeString(UserSeenStatus.ActivityType.Join);
                    string         nick_time   = status.GetActivityTimeString(UserSeenStatus.ActivityType.NicknameChange);
                    string         text_time   = status.GetActivityTimeString(UserSeenStatus.ActivityType.Chat);

                    client.LocalUser.SendMessage(targets, $"action_time: {action_time} quit_time: {quit_time} join_time: {join_time} nick_time: {nick_time} text_time: {text_time}");
                }
                else
                {
                    client.LocalUser.SendMessage(targets, "I see nothing, nothing!");
                }
            }
        }