public void ProcessGroupMessage(GroupMessageReceivedContext context) { // 只上报#开头的晚安式消息 string message = context.Message; message = message.Trim(); if (message.StartsWith("#")) { ulong from_qq = Convert.ToUInt64(context.FromQq); ulong from_group = Convert.ToUInt64(context.FromGroup); ulong add_time = Convert.ToUInt64(UnixTimestamp.GetTimeStampLong()); string nick_name = string.Empty; try { nick_name = _mahuaApi.GetGroupMemberInfo(context.FromGroup, context.FromQq).NickName; } catch { nick_name = from_qq.ToString(); } AutoGoodNightLogCache cache = new AutoGoodNightLogCache(); cache.Init(dbConnString); try { string localPath = AppDomain.CurrentDomain.BaseDirectory; localPath = Path.Combine(localPath, "data", "image"); // 图片酷Q码的转换 message = _replaceMsg(localPath, message); // Emojid酷Q码的转换,暂时调整到获取的时候在转换 // message = CqpEmoji.EmojiStringToNormalString(message); cache.InsertLog(from_qq, from_group, message, add_time, nick_name); } catch (Exception e) { ILog Logger = Newbe.Mahua.Logging.LogProvider.For <string>(); Logger.Debug(e.StackTrace); } } }
public JsonResult GetGoodNightMsgList() { VerifySign(); long from_group = GetLongParams("from_group"); CheckFromGroupToToken(); string good_night_key = GetStrParams("good_night_key"); good_night_key = $"#{good_night_key}#"; string dbConnectionStr = "Database=***;Data Source=***;User ID=***;Password=***;CharSet=utf8mb4;SslMode=None;Connect Timeout=60;"; AutoGoodNightLogCache cache = new AutoGoodNightLogCache(); cache.Init(dbConnectionStr); List <AutoGoodNightLogModel> list = cache.GetModelList(Convert.ToUInt64(from_group), good_night_key); List <Dictionary <string, object> > result = new List <Dictionary <string, object> >(); foreach (AutoGoodNightLogModel item in list) { Dictionary <string, object> m = new Dictionary <string, object>(); m["from_qq"] = item.from_qq; m["from_group"] = item.from_group; m["add_time"] = item.add_time; m["message"] = CqpEmoji.EmojiStringToNormalString(item.message); m["nick_name"] = item.nick_name; result.Add(m); } Dictionary <string, object> ret = new Dictionary <string, object>(); ret["errcode"] = 0; ret["data"] = result; ret["message"] = ""; return(Json(ret, JsonRequestBehavior.AllowGet)); }