Beispiel #1
0
 public IrcLine(string sender, IrcUser user, string command, string[] args, string final, string raw)
 {
     Sender = sender;
     User = user;
     Command = command;
     Arguments = args;
     FinalArgument = final;
     RawLine = raw;
 }
Beispiel #2
0
 private void ProcessNotice(IrcUser sender, string notice)
 {
     if (sender.Nick == "NickServ" && sender.Ident == "NickServ")
     {
         ProcessNickservReply(sender, notice);
     }
     else
     {
         OnNoticeReceived?.Invoke(sender, notice);
     }
 }
Beispiel #3
0
        internal void ProcessNickservReply(IrcUser sender, string notice)
        {
            if (notice.StartsWith("Information on "))
            {
                collectingNickservInformation = true;
                var data = notice.Substring("Information on  ".Length);

                var nick = data.Substring(0, data.IndexOf(" ", StringComparison.InvariantCulture) - 1);
                data = data.Substring(nick.Length + 2 + "(account  ".Length);
                var nickserv = data.Substring(0, data.Length - 3);

                information = new NickservInformation();
                information.Nickname = nick;
                information.AccountName = nickserv;
            }
            else if (notice.EndsWith("is not registered."))
            {
                var nick = notice.Substring(1, notice.Length - 2);
                nick = nick.Substring(0, nick.IndexOf(' ') - 1);
                OnNickservInformationReceived?.Invoke(null);
            }else if (collectingNickservInformation)
            {
                if (Regex.IsMatch(notice, @"\*\*\*.?\s+.?[Ee]nd [Oo]f [Ii]nfo.?\s+.?\*\*\*"))
                {
                    collectingNickservInformation = false;
                    var toSend = information;
                    information = null;
                    OnNickservInformationReceived?.Invoke(toSend);
                    return;
                }
                var match = Regex.Match(notice, @"^[Rr]egistered\s+:\s+(.*) \(.*\)$");
                if (match.Success)
                {
                    information.Registered = DateTime.ParseExact(match.Groups[1].Value, "MMM d HH:mm:ss yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
                    return;
                }
                match = Regex.Match(notice, @"^[Ee]ntity [Ii][Dd]\s+:\s+(.*)$");
                if (match.Success)
                {
                    information.EntityID = match.Groups[1].Value;
                    return;
                }
                match = Regex.Match(notice, @"^[Ll]ast [Aa]ddr\s+:\s+(.*)$");
                if (match.Success)
                {
                    information.LastAddress = match.Groups[1].Value;
                    return;
                }
                match = Regex.Match(notice, @"^[Ll]ast [Ss]een\s+:\s+(.*) \(.*\)$");
                if (match.Success)
                {
                    information.LastSeen = DateTime.ParseExact(match.Groups[1].Value, "MMM d HH:mm:ss yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
                    return;
                }
                match = Regex.Match(notice, @"[Ll]ast [Ss]een\s+:\s+[Nn]ow$");
                if (match.Success)
                {
                    information.LastSeen = DateTime.UtcNow;
                    return;
                }
                match = Regex.Match(notice, @"^[Ff]lags\s+:\s+(.*)$");
                if (match.Success)
                {
                    information.Flags = match.Groups[1].Value;
                    return;
                }
                match = Regex.Match(notice, @"^.*\s+has enabled nick protection$");
                if (match.Success)
                {
                    return;
                }
                Log("Ignoring unrecognised NickServ reply: " + notice);
            }
        }