Exemple #1
0
        private void Irc_RawMessageRecieved(object sender, IRC_Client.Events.RawMessageEventArgs e)
        {
            string raw = e.Message;

            if (raw.ContainsAny(out string spliType, false, PRIVMSG, USERNOTICE))
            {
                MessageCount++;
                if (spliType.Equals(USERNOTICE))
                {
                    var channelName = raw.GetBetween(spliType + " #", " :");
                    var parameters  = ParseParams(raw, spliType);
                    var Name        = raw.GetBetween("login="******";");
                    var Message     = raw.Substring("#" + channelName + " :");

                    var eventType = EventType.none;
                    var months    = 0;
                    var subType   = SubType.NoSub;
                    var time      = DateTime.Now;

                    if (parameters.ContainsKey(irc_params.tmi_sent_ts))
                    {
                        if (long.TryParse(parameters[irc_params.tmi_sent_ts], out long timeSeconds))
                        {
                            time = FromMillisecondsSinceUnixEpoch(timeSeconds);
                        }
                    }

                    if (parameters.ContainsKey(irc_params.msg_id))
                    {
                        //subgift == MSG_ID Subgift
                        Enum.TryParse(parameters[irc_params.msg_id], out eventType);
                    }
                    if (parameters.ContainsKey(irc_params.msg_param_months))
                    {
                        int.TryParse(parameters[irc_params.msg_param_months], out months);
                    }
                    if (parameters.ContainsKey(irc_params.msg_param_sub_plan))
                    {
                        Enum.TryParse(parameters[irc_params.msg_param_sub_plan], out subType);
                    }

                    var subMessage = new SubMessage()
                    {
                        Name = Name, Message = Message, Amount = months, SubType = subType, Time = time, EventType = eventType
                    };
                    SubList.Add(subMessage);

                    OnSubReceived?.Invoke(subMessage);
                }
            }
        }
Exemple #2
0
 private void Irc_OnSubReceived1(SubMessage message)
 {
     try
     {
         foreach (var eve in Events)
         {
             if (eve.Check(message))
             {
                 Action t = new Action(() => FireEvent(eve));
                 queue.Enqueue(t);
             }
         }
     }
     catch
     {
     }
     OnSubReceived?.Invoke(message);
 }