Exemple #1
0
    public string RTX_SendIM(string sSender, string sPwd, string sMsg, string sReceiver)
    {
        string sErr = "";

        try
        {
            RTXSAPIRootObj RootObj = new RTXSAPIRootObj(); //创建根对象
            RootObj.ServerIP   = "192.168.1.3";
            RootObj.ServerPort = 8006;
            string sSessionID = "{f1b15e85-2542-4220-90b8-8be3661eaa38}";
            RootObj.SendIM(sSender, sPwd, sReceiver, sMsg, sSessionID);
        }
        catch (Exception ex)
        {
            sErr = ex.Message;
        }
        return(sErr);
    }
Exemple #2
0
        protected virtual bool SendIM(string bstrSender, string bstrPwd, string bstrReceivers, string bstrMsg)
        {
            try
            {
                if (IsClosed == true)
                {
                    return(true);
                }

                if (IsDebug == true)
                {
                    bstrReceivers = DebugRtx;
                }

                RootObj.SendIM(bstrSender, bstrPwd, bstrReceivers, bstrMsg, string.Format("{{{0}}}", Guid.NewGuid()));
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
 /// <summary>
 /// 接收到RTX消息
 /// </summary>
 private void RecvMessageEvent(RTXSAPILib.IRTXSAPIMessage ms)
 {
     try
     {
         Rdata     = RootObj.CreateRTXSData();
         Rdata.XML = ms.Content;
         if (Rdata.XML != null)
         {
             string s1        = "Txt&gt;";
             string s2        = "&lt;/Txt";
             string content   = FindMatchStr(s1, s2, Rdata.XML);
             string groupName = Rdata.GetString("Title");
             long   mode      = Rdata.GetLong("Mode");
             string matchName = FindMatchStr("@", " ", Rdata.XML);
             if (matchName.Length > 0)
             {
                 string sendMsg = "时间:" + DateTime.Now + "\n";
                 if (mode == 4 && groupName != string.Empty && content != groupName)
                 {
                     sendMsg += "群名称:" + groupName + "\n";
                 }
                 sendMsg += "内容:" + content;
                 RootObj.SendNotify(matchName, ms.Sender + "@了你", Convert.ToInt32(Convert.ToDouble(tboxSysAlertTime.Text) * 1000), sendMsg);
             }
         }
         if (ms.Content.IndexOf("DisGroupId") != -1)
         {
             long groupID = Rdata.GetLong("DisGroupId");
             if (groupID == 10001)
             {
                 string s1        = "Txt&gt;";
                 string s2        = "&lt;/Txt";
                 string content   = FindMatchStr(s1, s2, Rdata.XML);
                 string receives  = ms.Sender + ";" + ms.Receivers;
                 string guid      = Rdata.GetString("Key");
                 string messageID = FindMatchStr("<Item Key=\"im_message_id\" Type=\"Buffer\">", "</Item>", Rdata.XML);
                 if (QADic.ContainsKey(content.Trim()))
                 {
                     if (alreadyRece.Contains(messageID))
                     {
                         return;
                     }
                     if (alreadyRece.Count >= 100)
                     {
                         alreadyRece.Clear();
                     }
                     alreadyRece.Add(messageID);
                     RootObj.SendIM(tboxRUser.Text, tboxRPSW.Text, receives, QADic[content], guid);
                 }
                 if (content.IndexOf("@小秘书 学习 问题:") != -1)
                 {
                     string question = FindMatchStr("@小秘书 学习 问题:", "回答:", content).Trim();
                     string answer   = FindMatchStr("回答:", s2, Rdata.XML);
                     if (question == "")
                     {
                         return;
                     }
                     else
                     {
                         if (QADic.Count <= 100)
                         {
                             if (QADic.ContainsKey(question))
                             {
                                 if (answer == QADic[question])
                                 {
                                     return;
                                 }
                                 RootObj.SendIM(tboxRUser.Text, tboxRPSW.Text, receives, "问题:" + question + "已经更新", guid);
                             }
                             QADic[question] = answer;
                         }
                         else
                         {
                             //学习的问题超过100个,人家脑子不大,不给你们记忆了嘛!!
                             RootObj.SendIM(tboxRUser.Text, tboxRPSW.Text, receives, "学习的问题超过100个,人家脑子不够用,不给你们记忆了嘛!!", guid);
                         }
                     }
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         WriteLog(ex.Message);
     }
 }