Пример #1
0
        private void analLogLine(string line)
        {
            //[16:19:16] AllChats AllChats, Broadcaster: てす
            MatchCollection mc = Regex.Matches(line, "\\[(?<hour>\\d+):(?<min>\\d+):(?<sec>\\d+)\\] (?<serv>\\S+) (?<servID>[^,]+), (?<auth>[^:]+): (?<mes>[^\n]+)");

            if (mc.Count > 0)
            {
                DateTime nlinetime = new DateTime(logPointTime.Ticks);
                nlinetime = nlinetime.AddHours(int.Parse(mc[0].Groups["hour"].Value) - nlinetime.Hour);
                nlinetime = nlinetime.AddMinutes(int.Parse(mc[0].Groups["min"].Value) - nlinetime.Minute);
                nlinetime = nlinetime.AddSeconds(int.Parse(mc[0].Groups["sec"].Value) - nlinetime.Second);

                tai.addTask(mc[0].Groups["mes"].Value, mc[0].Groups["servID"].Value, mc[0].Groups["auth"].Value, "", this, mc[0].Groups["serv"].Value);
            }
        }
Пример #2
0
        private void TcpListenLoop()
        {
            while (enable)
            {
                try
                {
                    server = new TcpListener(System.Net.IPAddress.Any, config.port);

                    server.Start();

                    TcpClient adept = server.AcceptTcpClient();

                    NetworkStream ns = adept.GetStream();
                    ns.ReadTimeout  = 1000;
                    ns.WriteTimeout = 1000;

                    AnkoData ndata = AnkoData.Load(ns);

                    /*
                     * MemoryStream ms = new MemoryStream();
                     * byte[] resByte = new byte[256];
                     * int rsize = 0;
                     * do
                     * {
                     *      rsize = ns.Read(resByte, 0, resByte.Length);
                     *      if (rsize == 0)
                     *      {
                     *              break;
                     *      }
                     *      ms.Write(resByte, 0, rsize);
                     * } while (ns.DataAvailable || resByte[rsize - 1] != '\n');
                     *
                     * string resMsg = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);//*/

                    adder.addTask(ndata.Message, ndata.AuthorID, ndata.AuthorName, "", this, "");

                    //ms.Close();

                    ns.Close();

                    adept.Close();

                    server.Stop();
                }
                catch { }
            }
        }
Пример #3
0
        private void ReadingLoop()
        {
            while (enable)
            {
                string videoID = "";
                try
                {
                    using (WebClient webClient = new WebClient())
                    {
                        string str = webClient.DownloadString("https://www.youtube.com/channel/" + configdata.ChannnelID + "/videos?flow=list&live_view=501&view=2");
                        //Console.Write(str);
                        Match mc = Regex.Match(str, "watch\\?v=([^\\\\\\\"]+)");
                        videoID = mc.Value.Replace("watch?v=", "");
                    }



                    var youtubeService = new YouTubeService(new BaseClientService.Initializer()
                    {
                        ApiKey          = configdata.APIKey,
                        ApplicationName = this.GetType().ToString()
                    });


                    var chatIDReq = youtubeService.Videos.List("liveStreamingDetails");

                    chatIDReq.Id = videoID;

                    var chatIDans = chatIDReq.Execute();

                    var mesReq = youtubeService.LiveChatMessages.List(chatIDans.Items[0].LiveStreamingDetails.ActiveLiveChatId, "snippet");
                    mesReq.MaxResults = 200;
                    var mesAns = mesReq.Execute();


                    //textBox1.Text = channelans.ToString();

                    foreach (var e in mesAns.Items)
                    {
                        if (DateTime.Parse(e.Snippet.PublishedAtRaw) > lasttime)
                        {
                            lasttime = DateTime.Parse(e.Snippet.PublishedAtRaw);
                            if (e.Snippet.TextMessageDetails != null & !(configdata.OnlySuperchat))
                            {
                                var nameReq = youtubeService.Channels.List("brandingSettings");
                                nameReq.Id = e.Snippet.AuthorChannelId;
                                var    name     = nameReq.Execute();
                                string auadinfo = "";
                                if (e.Snippet.AuthorChannelId == configdata.ChannnelID)
                                {
                                    auadinfo = "owner";
                                }
                                else
                                {
                                    try
                                    {
                                        var ModeratorsReq = youtubeService.LiveChatModerators.List(chatIDans.Items[0].LiveStreamingDetails.ActiveLiveChatId, "snippet");
                                        var Moderators    = ModeratorsReq.Execute();
                                        if (Moderators.Items.Any(x => x.Snippet.ModeratorDetails.ChannelId == configdata.ChannnelID))
                                        {
                                            auadinfo = "moderator";
                                        }
                                    }
                                    catch { }
                                }
                                tai.addTask(e.Snippet.TextMessageDetails.MessageText, e.Snippet.AuthorChannelId, name.Items[0].BrandingSettings.Channel.Title, auadinfo, this, "");
                            }

                            if (e.Snippet.SuperChatDetails != null)
                            {
                                var nameReq = youtubeService.Channels.List("brandingSettings");
                                nameReq.Id = e.Snippet.AuthorChannelId;
                                var    name     = nameReq.Execute();
                                string supermes = e.Snippet.SuperChatDetails.UserComment;
                                if (supermes == null)
                                {
                                    supermes = "";
                                }
                                tai.addTask(supermes, e.Snippet.AuthorChannelId, name.Items[0].BrandingSettings.Channel.Title, "SuperChat", this, e.Snippet.SuperChatDetails.AmountDisplayString);
                            }
                        }
                    }
                }
                catch { }
                Thread.Sleep(1000);
            }
        }