Beispiel #1
0
        /// <summary>
        /// 检查关键词
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string CheckKeyWordAsync(GroupMessageReceivedContext context)
        {
            //btc
            Regex regEnglish = new Regex("^[a-z]");

            if (context.Message.Length < 5 && regEnglish.IsMatch(context.Message))
            {
                string key = ConfigManager.CheckSymbol(context.Message);
                if (!string.IsNullOrEmpty(key))
                {
                    string re = _coinmarketcapService.GetTicker(context.Message).Result;
                    return(re);
                }
            }

            //查币价 eos btc
            if (context.Message.Length > 4 && context.Message.Substring(0, 4).Equals("查币价 "))
            {
                string key = context.Message.Remove(0, 4);

                string reOkex  = _okexService.Ticker(key).Result;
                string reHuobi = _huobiService.Ticker(key).Result;

                string[] keys = context.Message.Split(' ');
                //eos
                string reCM = _coinmarketcapService.GetTicker(keys[1]).Result;

                return("【okex】" + reOkex + "\n【火币】" + reHuobi + "\n【cm】" + reCM);
            }

            //场外币价
            if (context.Message.Equals("场外币价"))
            {
                string huobiOTC = _huobiService.LegalTender().Result;

                return(huobiOTC);
            }

            //币圈消息
            if (context.Message.Equals("币圈消息"))
            {
                NewsResult[] re     = _newsService.RequestBiQuanApi();
                string       reNews = re[0].From + re[0].Content;
                for (int i = 1; i < re.Length; i++)
                {
                    reNews += "\n" + re[i].From + re[i].Content;
                }
                return(reNews);
            }

            //早报
            if (context.Message.Equals("早报"))
            {
                string reNews = _pmtownService.GetMorningPapaer().Result;
                return(reNews);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 检查关键词
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string CheckKeyWordAsync(GroupMessageReceivedContext context)
        {
            //btc
            Regex regEnglish = new Regex("^[a-z]");

            if (context.Message.Length < 5 && regEnglish.IsMatch(context.Message))
            {
                string key = ConfigManager.CheckSymbol(context.Message);
                if (!string.IsNullOrEmpty(key))
                {
                    string re = _coinmarketcapService.GetTicker(context.Message).Result;
                    return(re);
                }
            }

            //查币价 eos btc
            if (context.Message.Length > 4 && context.Message.Substring(0, 4).Equals("查币价 "))
            {
                string key = context.Message.Remove(0, 4);

                string reOkex  = _okexService.Ticker(key).Result;
                string reHuobi = _huobiService.Ticker(key).Result;

                string[] keys = context.Message.Split(' ');
                //eos
                string reCM = _coinmarketcapService.GetTicker(keys[1]).Result;

                return("【okex】" + reOkex + "\n【火币】" + reHuobi + "\n【cm】" + reCM);
            }

            //场外币价
            if (context.Message.Equals("场外币价"))
            {
                string huobiOTC = _huobiService.LegalTender().Result;

                return(huobiOTC);
            }

            return(null);
        }
Beispiel #3
0
        private void CheckCoinNews()
        {
            ConfigManager.Instance().pushProblemCount += 1;
            if (ConfigManager.Instance().pushProblemCount > (4 * 60 * 60 / ConfigManager.pushNewsConfig.LoopCheckTime))
            {
                var msg = ConfigManager.Instance().problem.description + "\n" + ConfigManager.Instance().problem.example;
                _mahuaApi.SendGroupMessage("417955323", msg);
                ConfigManager.Instance().pushProblemCount = 0;
            }

            var re = _newsService.RequestBiQuanApi();

            NewsResult msg1 = null;
            NewsResult msg2 = null;
            NewsResult msg3 = null;
            NewsResult msg4 = null;

            if (re[0] != null && !re[0].Content.Equals(lastMsg1))
            {
                lastMsg1 = re[0].Content;
                msg1     = re[0];
            }
            else
            {
                msg1 = null;
            }

            if (re[1] != null && !re[1].Content.Equals(lastMsg2))
            {
                lastMsg2 = re[1].Content;
                msg2     = re[1];
            }
            else
            {
                msg2 = null;
            }

            if (re[2] != null && !re[2].Content.Equals(lastMsg3))
            {
                lastMsg3 = re[2].Content;
                msg3     = re[2];
            }
            else
            {
                msg3 = null;
            }

            if (re[3] != null && !re[3].Content.Equals(lastMsg4))
            {
                lastMsg4 = re[3].Content;
                msg4     = re[3];
            }
            else
            {
                msg4 = null;
            }

            if (ConfigManager.pushNewsConfig.UsCompute)
            {
                if (msg1 != null)
                {
                    StringCompute stringcompute1 = new StringCompute();
                    stringcompute1.Compute(msg1.Content, lastMsg2);
                    if ((float)stringcompute1.ComputeResult.Rate > ConfigManager.pushNewsConfig.ComputeRate)
                    {
                        msg1 = null;
                    }
                }
                if (msg2 != null)
                {
                    StringCompute stringcompute1 = new StringCompute();
                    stringcompute1.Compute(msg2.Content, lastMsg1);
                    if ((float)stringcompute1.ComputeResult.Rate > ConfigManager.pushNewsConfig.ComputeRate)
                    {
                        msg2 = null;
                    }
                }

                if (msg1 != null && msg2 != null)
                {
                    StringCompute stringcompute1 = new StringCompute();
                    stringcompute1.Compute(msg1.Content, msg2.Content);
                    if ((float)stringcompute1.ComputeResult.Rate > ConfigManager.pushNewsConfig.ComputeRate)
                    {
                        msg2 = null;
                    }
                }
            }

            var reMsg = string.Empty;

            if (msg1 != null)
            {
                if (msg1.NewsLevel == NewsLevel.Normal)
                {
                    normalMsgList.Add(msg1.From + msg1.Title + "\n");
                }
                else
                {
                    reMsg += msg1.From + msg1.Title + "\n";
                }
            }
            if (msg2 != null)
            {
                if (msg2.NewsLevel == NewsLevel.Normal)
                {
                    normalMsgList.Add(msg2.From + msg2.Content + "\n");
                }
                else
                {
                    reMsg += msg2.From + msg2.Title + "\n";
                }
            }
            if (msg3 != null)
            {
                if (msg3.NewsLevel == NewsLevel.Normal)
                {
                    normalMsgList.Add(msg3.From + msg3.Title + "\n");
                }
                else
                {
                    reMsg += msg3.From + msg3.Title + "\n";
                }
            }
            if (msg4 != null)
            {
                if (msg4.NewsLevel == NewsLevel.Normal)
                {
                    normalMsgList.Add(msg4.From + msg4.Title + "\n");
                }
                else
                {
                    reMsg += msg4.From + msg4.Title + "\n";
                }
            }

            if (!string.IsNullOrEmpty(reMsg))
            {
                //查询币圈
                reMsg += _coinmarketcapService.GetTicker("btc").Result;
                reMsg += "\n" + _huobiService.LegalTender().Result;

                //涨跌幅排名
                //reMsg += "\n【OK涨幅排名】"+_coinService.GetOkexTopTracks();
                //reMsg += "\n【OK跌幅排名】" + _coinService.GetOkexBottomTracks();

                if (sendCount != 0)
                {
                    foreach (var group in ConfigManager.pushNewsConfig.CoinNewsPushGroupList)
                    {
                        _mahuaApi.SendGroupMessage(group, reMsg + "\n第" + sendCount + "次主动推送消息");
                    }
                }
                sendCount++;
            }

            if (nowNormalNewsPushIntervalCount < ConfigManager.pushNewsConfig.NormalNewsPushIntervalCount)
            {
                nowNormalNewsPushIntervalCount++;
            }
            else
            {
                if (sendCount != 0)
                {
                    var normalMsg = string.Empty;
                    foreach (var item in normalMsgList)
                    {
                        normalMsg += item;
                    }
                    normalMsgList.Clear();


                    if (!string.IsNullOrEmpty(normalMsg))
                    {
                        //查询币圈
                        normalMsg += _coinmarketcapService.GetTicker("btc").Result;
                        normalMsg += "\n" + _huobiService.LegalTender().Result;

                        foreach (var group in ConfigManager.pushNewsConfig.CoinNewsPushGroupList)
                        {
                            _mahuaApi.SendGroupMessage(group, normalMsg + "\n第" + sendCount + "次主动推送消息");
                        }
                    }
                }
                sendCount++;
                nowNormalNewsPushIntervalCount = 0;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 检查是否有新的新闻
        /// http://larkbot.evesgf.com/api/News/GetPaomianLatestNews
        /// </summary>
        public void CheckNews()
        {
            var re = _newsService.RequestBiQuanApi();

            string msg1 = null;

            if (lastMsg1 != re[0])
            {
                lastMsg1 = re[0];
                msg1     = re[0] + "\n";
            }
            else
            {
                msg1 = null;
            }

            string msg2 = null;

            if (lastMsg2 != re[1])
            {
                lastMsg2 = re[1];
                msg2     = re[1] + "\n";
            }
            else
            {
                msg2 = null;
            }

            string msg3 = null;

            if (lastMsg3 != re[2])
            {
                lastMsg3 = re[2];
                msg3     = re[2] + "\n";
            }
            else
            {
                msg3 = null;
            }

            string msg4 = null;

            if (lastMsg4 != re[3])
            {
                lastMsg4 = re[3];
                msg4     = re[3] + "\n";
            }
            else
            {
                msg4 = null;
            }

            if (msg1 != null || msg2 != null || msg3 != null || msg4 != null)
            {
                string reMsg = msg1 + msg2 + msg3 + msg4;

                //reMsg += "【场外币价】";
                //var re2 = _coinService.OTCPrice().Data;
                //foreach (var str in re2)
                //{
                //    reMsg += str + "\n";
                //}

                //查询币圈
                reMsg += _coinmarketcapService.GetTicker("btc").Result;
                reMsg += "\n" + _huobiService.LegalTender().Result;

                //涨跌幅排名
                //reMsg += "\n【OK涨幅排名】"+_coinService.GetOkexTopTracks();
                //reMsg += "\n【OK跌幅排名】" + _coinService.GetOkexBottomTracks();

                SendNews(reMsg + "\n第" + sendCount + "次主动推送消息");
                sendCount++;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 检查关键词
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string CheckKeyWordAsync(GroupMessageReceivedContext context)
        {
            //btc
            Regex regEnglish = new Regex("^[a-z]");

            if (context.Message.Length < 7 && regEnglish.IsMatch(context.Message))
            {
                string key = ConfigManager.CheckSymbol(context.Message);
                if (!string.IsNullOrEmpty(key))
                {
                    string re = _coinmarketcapService.GetTicker(context.Message).Result;
                    return(re);
                }
            }

            //查币价 eos btc
            if (context.Message.Length > 4 && context.Message.Substring(0, 4).Equals("查币价 "))
            {
                string key = context.Message.Remove(0, 4);

                string reOkex  = _okexService.Ticker(key).Result;
                string reHuobi = _huobiService.Ticker(key).Result;

                string[] keys = context.Message.Split(' ');
                //eos
                string reCM = _coinmarketcapService.GetTicker(keys[1]).Result;

                return("【okex】" + reOkex + "\n【火币】" + reHuobi + "\n【cm】" + reCM);
            }

            //场外币价
            if (context.Message.Equals("场外币价"))
            {
                string huobiOTC = _huobiService.LegalTender().Result;

                return(huobiOTC);
            }

            //币圈消息
            if (context.Message.Equals("币圈消息"))
            {
                NewsResult[] re     = _newsService.RequestBiQuanApi();
                string       reNews = re[0].From + re[0].Content;
                for (int i = 1; i < re.Length; i++)
                {
                    if (re[i] != null)
                    {
                        reNews += "\n" + re[i].From + re[i].Content;
                    }
                }
                return(reNews);
            }

            //早报
            if (context.Message.Equals("早报"))
            {
                string reNews = _pmtownService.GetMorningPapaer().Result;
                return(reNews);
            }

            //早报
            if (context.Message.Equals("每日一题"))
            {
                string reNews = _problemService.GetRundomProblem();
                return(reNews);
            }

            //搜题 unity
            if (context.Message.Length > 3 && context.Message.Substring(0, 3).Equals("搜题 "))
            {
                string key = context.Message.Remove(0, 3);

                string reNews = _problemService.GetRundomRoblemToTag(key);
                return(reNews);
            }

            //Roll
            if (context.Message.Length == 4 && context.Message.Equals("roll"))
            {
                var coin = new Random().Next(0, 100);
                if (coin == 100)
                {
                    return(coin.ToString() + " 欧皇在世!!!");
                }
                if (coin >= 90)
                {
                    return(coin.ToString() + " 金色传说!");
                }
                else if (coin >= 80)
                {
                    return(coin.ToString() + " 传说!");
                }
                else if (coin >= 70)
                {
                    return(coin.ToString() + " 史诗!");
                }
                else if (coin >= 60)
                {
                    return(coin.ToString() + " 稀有!");
                }
                else if (coin < 60 && coin > 10)
                {
                    return(coin.ToString() + " 非酋预定~");
                }
                else
                {
                    return(coin.ToString() + " 真·非酋~");
                }
            }

            //Roll
            if (context.Message.Length == 2 && context.Message.Equals("刷题"))
            {
                return(_lintCodeService.RefshNowProblem());
            }

            //Roll
            if (context.Message.Length == 4 && context.Message.Equals("今日题目"))
            {
                return(_lintCodeService.GetNowProblem());
            }

            //Roll
            if (context.Message.Length == 4 && context.Message.Equals("查看答案"))
            {
                return(_lintCodeService.GetNowAnswer());
            }

            //Roll
            if (context.Message.Length == 5 && context.Message.Equals("杨老师好帅"))
            {
                return("等杨老师下班回家就加上答案");
            }

            //复读机
            if (new Random().Next(0, 100) > 98)
            {
                return(context.Message);
            }

            //检测复读
            if (context.Message.Equals(ConfigManager.lastMessage) && ConfigManager.lastMessage.Equals(ConfigManager.lastLastMessage) && ConfigManager.lastLastMessage.Equals(ConfigManager.lastLastLastMessage) && (DateTime.Now.Minute - ConfigManager.reReadTime.Minute) > 1)
            {
                ConfigManager.lastMessage         = "";
                ConfigManager.lastLastMessage     = "";
                ConfigManager.lastLastLastMessage = "";
                ConfigManager.reReadTime          = DateTime.Now;
                return(context.Message);
            }


            ConfigManager.lastLastLastMessage = ConfigManager.lastLastMessage;
            ConfigManager.lastLastMessage     = ConfigManager.lastMessage;
            ConfigManager.lastMessage         = context.Message;

            return(null);
        }