Пример #1
0
        public JsonModel.ReqResult sendXmlMessage(long target, string xml, int target_type, long through_group = 0, long at_user = 0)
        {
            JObject jb = new JObject
            {
                { "atUser", at_user },
                { "content", xml },
                { "groupid", through_group },
                { "sendMsgType", "XmlMsg" },
                { "sendToType", target_type },
                { "toUser", target }
            };
            string json = jb.ToString();

            json = json.Replace("<", "\\u003c").Replace(">", "\\u003e");
            string str = LuaApiCaller("SendMsg", json);

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(str);
            if (retv.Ret == 0)
            {
                logger("debug_sendmsg_result", "Succeed.");
            }
            else
            {
                logger("debug_sendmsg_result", "Fail.");
            }

            return(retv);
        }
Пример #2
0
        /// <summary>
        /// 发送一条文字信息
        /// </summary>
        /// <param name="target">发送到的目标QQ号或群号</param>
        /// <param name="msg">消息文字内容(支持iotqq指令)</param>
        /// <param name="target_type">目标类型</param>
        /// <param name="through_group">通过指定群发动临时聊天(如果有)</param>
        /// <param name="at_user">要at的人的QQ(如果有)</param>
        /// <returns></returns>
        public JsonModel.ReqResult sendTextMessage(long target, string msg, int target_type, long through_group = 0, long at_user = 0)
        {
            JsonModel.TextMessage msgi = new JsonModel.TextMessage()
            {
                atUser      = at_user,
                content     = msg,
                groupid     = through_group,
                sendMsgType = "TextMsg",
                sendToType  = target_type,
                toUser      = target
            };
            string json = System.Text.Json.JsonSerializer.Serialize(msgi);
            string str  = LuaApiCaller("SendMsg", json);

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(str);
            if (retv == null)
            {
                return(null);
            }

            if (retv.Ret == 0)
            {
                logger("debug_sendmsg_result", "Succeed.");
            }
            else
            {
                logger("debug_sendmsg_result", "Fail.");
            }

            return(retv);
        }
Пример #3
0
        /// <summary>
        /// 处理入群申请
        /// </summary>
        /// <param name="seq">申请信息(接收到申请时的完整EventData)</param>
        /// <param name="pass">true=同意,false=拒绝</param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool doGroupEnterReq(JObject seq, bool pass, string msg = null)
        {
            JObject jb = (JObject)seq.DeepClone();

            jb["Action"]        = pass ? 11 : 12;//14忽略
            jb["RefuseContent"] = msg;
            string ret = LuaApiCaller("AnswerInviteGroup", jb.ToString());

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(ret);
            return(retv.Ret == 0);
        }
Пример #4
0
        /// <summary>
        /// 全体禁言
        /// </summary>
        /// <param name="group">群号</param>
        /// <param name="enable">true=禁,false=解禁</param>
        /// <param name="len">时长(min),此处通常无效</param>
        /// <returns></returns>
        public JsonModel.ReqResult shutAll(long group, bool enable = true, int len = 0)
        {
            JsonModel.ShutupReq req = new JsonModel.ShutupReq()
            {
                GroupID    = group,
                ShutUID    = enable ? 15 : 0,
                ShutTime   = len,
                ShutUpType = 1
            };
            string json = System.Text.Json.JsonSerializer.Serialize(req);

            logger("debug_shutupuser_step", "Requesting iotbot server...");
            string ret = LuaApiCaller("ShutUp", json);

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(ret);
            logger("debug_shutupuser_step", "Done");
            return(retv);
        }
Пример #5
0
        public JsonModel.ReqResult changeMemberNameCard(long group, long member, string namecard)
        {
            //ModifyGroupCard
            JObject jb = new JObject
            {
                { "GroupID", group },
                { "UserID", member },
                { "NewNick", namecard }
            };
            string ret = LuaApiCaller("ModifyGroupCard", jb.ToString());

            if (ret == null)
            {
                return(null);
            }

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(ret);
            return(retv);
        }
Пример #6
0
        public JsonModel.ReqResult RevokeMessage(long group, int seq, long rand, bool retry = true)
        {
            JObject jb = new JObject
            {
                { "GroupID", group },
                { "MsgSeq", seq },
                { "MsgRandom", rand }
            };
            string ret = LuaApiCaller("RevokeMsg", jb.ToString());

            if (ret == null && retry)
            {
                return(RevokeMessage(group, seq, rand, false));
            }

            if (ret == null)
            {
                return(null);
            }

            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(ret);
            return(retv);
        }
Пример #7
0
        /// <summary>
        /// 发图片
        /// </summary>
        /// <param name="target">目标QQ号或群号</param>
        /// <param name="msg">文本消息内容</param>
        /// <param name="target_type">目标类型</param>
        /// <param name="picurl">图片地址</param>
        /// <param name="through_group">临时聊天通过的群号(0=不通过临时聊天)</param>
        /// <param name="at_user">被at的人</param>
        /// <returns></returns>
        public JsonModel.ReqResult sendPicMessage(long target, string msg, int target_type, string picurl, long through_group = 0, long at_user = 0)
        {
            JsonModel.PicMessage msgi = new JsonModel.PicMessage()
            {
                atUser       = at_user,
                content      = msg,
                groupid      = through_group,
                sendMsgType  = "PicMsg",
                sendToType   = target_type,
                toUser       = target,
                picUrl       = picurl,
                fileMd5      = "",
                picBase64Buf = ""
            };
            string json = System.Text.Json.JsonSerializer.Serialize(msgi);

            logger("debug_sendmsg_reqjson", json);
            logger("debug_sendmsg_step", "Requesting iotbot server...");
            string str = LuaApiCaller("SendMsg", json);

            logger("debug_sendmsg_step", "End requesting iotbot server. Done.");
            logger("debug_sendmsg_retjson", str);
            JsonModel.ReqResult retv = System.Text.Json.JsonSerializer.Deserialize <JsonModel.ReqResult>(str);
            try
            {
                if (retv.Ret == 0)
                {
                    logger("debug_sendmsg_result", "Succeed.");
                }
                else
                {
                    logger("debug_sendmsg_result", "Fail.");
                }
            }
            catch { }
            return(retv);
        }