【QQ机器人】UIBOT如何获取QQ群聊里的用户QQ号

ddd_29693 5月前 379

虽然现在大多数QQ机器人使用的都是手姬(屏蔽词)版的QRSpeed,但个人还是打算使用uibot做一个属于自己的机器人

但是目前来看,有一个比较致命的问题,就是新版本的QQ群聊,只显示群成员的名称,不显示QQ号,而且尝试了各种方法也找不到可以读取QQ号的途径(虽然可以获取到一个成员消息,然后模拟操作打开对话,再获取QQ号,但这样毕竟太浪费时间了,一次至少1秒,对于秒回来说,已经相当致命了)


总体来说互动性还是很强的,但目前来说,有2个问题非常致命

1、可能是电脑端的问题,暂时无法做法逐条检测,如果在非常短的时间内,比如说0.1秒内同时有3-5个群成员说话,可能检测到的只有后面的2条,前面的被刷下去的就没了,这个问题是可以解决,但咱暂时找不到不影响效率的同时还能秒回。

这个问题其实也不是很大。目前基本2条消息能同时检测,很少有同时发送3条以上消息的。

2、再就是只能检测到群成员名称了,如代码中,我只能根据名称来设置主人、管理员,如果有群成员改了名称和管理员一样,那么他就可以随意控制机器人了。(目前暂时找不到快速处理方法,显示号码的群聊老版本QQ现在也已经不能用了。目前是有2个可以解决,但很影响效率:1、点击用户打开会话窗口,再获取QQ号;2、点击聊天记录,也会有QQ号,但每次获取都需要关闭聊天记录,打开聊天记录,那么才会刷新,也很影响效率)


所以来论坛和大佬们一起讨论一下,有没有解决方法,或者实际有解决方法,但是我一直没找到  呜呜呜 ,请教!

谢谢各位大佬们了!

_【QQ机器人】UIBOT如何获取QQ群聊里的用户QQ号

_【QQ机器人】UIBOT如何获取QQ群聊里的用户QQ号

_【QQ机器人】UIBOT如何获取QQ群聊里的用户QQ号_【QQ机器人】UIBOT如何获取QQ群聊里的用户QQ号

    objExcelWorkBook = Excel.BindBook("智障机器人的智障回复.xlsx")
    Dim objRet = ""
    iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
    arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet1","A1:C"&iRet)
    FF=1
    Dim sRet = ""
    Dim arrRet = ""
    Dim sRet_1=""                   
    Dim lianxu_max=0
    dTime2=0
    //Dim qunmingcheng="妖怪百姬日服破解交流群"
    Dim qunmingcheng="ウマ娘 马娘Pretty Derby游戏群"
    Dim ziji="艾丽莎"

    Do While 1
        o=0
        oo=0
        Do While sRet=sRet_1
            #icon("@res:p1h4togk-lopd-j6bs-8llf-osqjqerndu0k.png")
            sRet = UiElement.GetValue({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":"QQ"}],"ctrl":[{"role":"ROLE_SYSTEM_PANE","name":"会话列表"},{"role":"ROLE_SYSTEM_PANE","name":"会话列表"},{"role":"ROLE_SYSTEM_LISTITEM","name":qunmingcheng}]},{"bContinueOnError":True,"iDelayAfter":o,"iDelayBefore":o})
            oo=oo+1
            If oo =5000 //高速读取次数
                o=100   //每次读取延时
                TracePrint("短时间无新消息,进入低速模式")
            ElseIf oo=7500
                o=200   //每次读取延时
                TracePrint("中时间无新消息,进入中速模式")
            ElseIf oo=10000
                o=500
                TracePrint("长时间无新消息,进入低速模式")
            End If
        Loop
        sRet_1=sRet
        iRet2 = InStr(sRet,":",1,False)
        name=Left(sRet_1,iRet2-1)
        sRet_A=Right(sRet,Len(sRet)-iRet2)
        TracePrint("最新一句为:"&sRet_A)
        If sRet_A="开机" And FF=0
            If name="舰载仓鼠" or "艾丽莎的主人" or name="玖月" or name="陈朵《S工会月供6000收人》"or name="热爱祖国热爱生活"or name="囤萝卜的Cb 16122/3w"or name="療愁治憂"or name="кк"or name="本群卑微号商在线乞讨"or name="寝不足寝不足寝不足寝不足寝不足寝不足"
                FF=1
                qq_re("艾丽莎已接通电源,复活啦!!~~",name)
            Else
                qq_re("请联xi主人或管理员进行开机",name)
            End If
        ElseIf FF=1
            If Left(sRet_A,6)="post##"
                add_sql(sRet_A,iRet,arrayRet)
                iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
                arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet1","A1:C"&iRet)
            ElseIf   Left(sRet_A,7)="postr##"
                add_sql2(sRet_A,iRet,arrayRet)
                iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
                arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet1","A1:C"&iRet)
            ElseIf   Left(sRet_A,8)="delete##"
                delete_sql(sRet_A,iRet,arrayRet)
                iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
                arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet1","A1:C"&iRet)
            End If
            If  sRet_A="关机"
                If name="舰载仓鼠" or "艾丽莎的主人" or name="玖月" or name="陈朵《S工会月供6000收人》"or name="热爱祖国热爱生活"or name="囤萝卜的Cb 16122/3w"or name="療愁治憂"or name="кк"or name="本群卑微号商在线乞讨"or name="寝不足寝不足寝不足寝不足寝不足寝不足"
                qq_re(ziji&"已断电自尽~",name)
                    FF=0
                    sRet_A=""
                Else
                    qq_re(ziji&"拒绝了你的关机,哒咩哟~",name)
                End If
            ElseIf   sRet_A="签到"
                qiandao("萝卜",name)
            ElseIf   sRet_A="马娘十连"
                shilian("马娘十连",name)
            ElseIf   sRet_A="抽卡十连"
                shilian("抽卡十连",name)
            ElseIf name<>ziji
                For i=0 To iRet-1
                    If sRet_A=arrayRet[i][0And arrayRet[i][2]=0
                        sRet_Q=arrayRet[i][1]
                        If   sRet_A="help"
                            qq_re(sRet_Q,"##")
                        Else
                            qq_re(sRet_Q,name)
                        End If
                        dTime1 = Time.Now()
                        dTime3 = Time.DateDiff("s",dTime2,dTime1)
                        If dTime3<5
                            lianxu_max=lianxu_max+1
                        Else
                            lianxu_max=0
                        End If 
                        dTime2=dTime1
                        If lianxu_max>=4
                            qq_re("怀疑"&ziji&"已进入永动机模式,已断电自尽",name)
                            Exit
                        End If
                        Break           
                    ElseIf (InStr(sRet_A,arrayRet[i][0],1,True)>0And arrayRet[i][2]=1
                        sRet_Q=arrayRet[i][1]
                        If   sRet_A="help"
                            qq_re(sRet_Q,"##")
                        Else
                            qq_re(sRet_Q,name)
                        End If
                        dTime1 = Time.Now()
                        dTime3 = Time.DateDiff("s",dTime2,dTime1)
                        If dTime3<5
                            lianxu_max=lianxu_max+1
                        Else
                            lianxu_max=0
                        End If 
                        dTime2=dTime1
                        If lianxu_max>=4
                            qq_re("怀疑"&ziji&"已进入永动机模式,已断电自尽",name)
                            Exit
                        End If
                        Break  
                    ElseIf sRet_A=arrayRet[i][0And arrayRet[i][2]=2
                        sRet_Q=arrayRet[i][1]
                        qq_rem(sRet_Q)
                        iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
                        arrayRet = Excel.ReadRange(objExcelWorkBook,"Sheet1","A1:C"&iRet)
                        Break  
                    End If 
                Next
            End If
        End If 
    Loop
    //添加数据库(文本,数据库行数,搜索类型(0一样,1匹配))
    Function add_sql(sRet_A,iRet,arrayRet)
        a1= InStr(sRet_A,"##",1,False)+2
        q1 = InStr(sRet_A,"##",a1,False)+2
        a = Mid(sRet_A,a1,q1-a1-2)
        b = Mid(sRet_A,q1,Len(sRet_A)-q1+1)
        l=1
        For i = 0 To iRet-1
            If b=arrayRet[i][0]
                qq_re("永动机哒咩!",name)
                a=""
                b=""
                l=0
                Break
            End If
        Next
        If l =1
            Excel.WriteCell(objExcelWorkBook,"Sheet1","C"&iRet+1,"0",False)
            Excel.WriteCell(objExcelWorkBook,"Sheet1","A"&iRet+1,a,False)
            Excel.WriteCell(objExcelWorkBook,"Sheet1","B"&iRet+1,b,True)
            qq_re("添加成功",name)
        End If
    End Function
    //添加数据库(文本,数据库行数,搜索类型(0一样,1匹配))
    Function add_sql2(sRet_A,iRet,arrayRet)
        a1= InStr(sRet_A,"##",1,False)+2
        q1 = InStr(sRet_A,"##",a1,False)+2
        a = Mid(sRet_A,a1,q1-a1-2)
        b = Mid(sRet_A,q1,Len(sRet_A)-q1+1)
        l=1
        For i = 0 To iRet-1
            If b=arrayRet[i][0]
                qq_re("永动机哒咩!",name)
                a=""
                b=""
                l=0
                Break
            End If
        Next
        If l =1
            Excel.WriteCell(objExcelWorkBook,"Sheet1","C"&iRet+1,"1",False)
            Excel.WriteCell(objExcelWorkBook,"Sheet1","A"&iRet+1,a,False)
            Excel.WriteCell(objExcelWorkBook,"Sheet1","B"&iRet+1,b,True)
            qq_re("添加成功",name)
        End If
    End Function
    //删除数据库(文本,数据库行数,搜索类型(0一样,1匹配))
    Function delete_sql(sRet_A,iRet,arrayRet)
        a1= InStr(sRet_A,"##",1,False)+2
        a = Mid(sRet_A,a1,Len(sRet_A)-a1+1)
        l=1
        For i = 0 To iRet-1
            If a=arrayRet[i][0]
                Excel.DeleteRow(objExcelWorkBook,"Sheet1","A"&i+1,True)
                qq_re("删除成功!",name)
                l=0
                Break
            End If
        Next
        If l =1
            qq_re("未找到关键词!",name)
        End If 
    End Function
    Function shilian(sheet,name) //十连
        iRet4 = Excel.GetRowsCount(objExcelWorkBook,"萝卜")
        arrayRet4 = Excel.ReadRange(objExcelWorkBook,"萝卜","E2:G"&iRet4)
        
        mingzibiaoshi=0
        For ii2= 2 To iRet4
            If name=arrayRet4[ii2-2][0]   //如果找到了对应的名字
                shengyuluobo= CInt(arrayRet4[ii2-2][1])   //剩余萝卜
                If shengyuluobo>=1500
                    shengyuluobo=shengyuluobo-1500
                    Excel.WriteCell(objExcelWorkBook,"萝卜","F"&ii2,shengyuluobo,False)
                    arrayRet1 = Excel.ReadRange(objExcelWorkBook,sheet,"H21")
                    qq_retm(arrayRet1[0][0],name,sheet)
                    mingzibiaoshi=1
                    Break
                Else
                    qq_re("##,你的萝卜不足啦~可以说“签到”获取萝卜哦~你的剩余萝卜:"&shengyuluobo,name)
                    mingzibiaoshi=1
                    Break
                End If
            End If
        Next
        If mingzibiaoshi=0
            Excel.WriteCell(objExcelWorkBook,"萝卜","E"&iRet4+1,name,False)  //添加名字
            Excel.WriteCell(objExcelWorkBook,"萝卜","F"&iRet4+1,0,False)  //添加萝卜数量
            Excel.WriteCell(objExcelWorkBook,"萝卜","G"&iRet4+1,0,False)  //更改签到标识
            qq_re("##,你的萝卜不足啦~可以说“签到”获取萝卜哦~你的剩余萝卜:"&0,name)
        End If
    End Function

    Function qiandao(sheet,name)  //签到
        Excel.WriteCell(objExcelWorkBook,sheet,"A12","1",False)
        today=CInt(Excel.ReadCell(objExcelWorkBook,sheet,"D2")) //随机萝卜
        iRet3 = Excel.GetRowsCount(objExcelWorkBook,sheet)
        arrayRet3 = Excel.ReadRange(objExcelWorkBook,sheet,"E2:G"&iRet3)
        
        If Time.Day(Time.Date())=today
            
        Else
            Excel.WriteCell(objExcelWorkBook,sheet,"D2",Time.Day(Time.Date()),False)
            Excel.WriteCell(objExcelWorkBook,sheet,"G2:G"&iRet3,0,False)
            arrayRet3 = Excel.ReadRange(objExcelWorkBook,sheet,"E2:G"&iRet3)
        End If
        mingzibiaoshi=0
        For ii = 2 To iRet3  //查找名字对应的萝卜数量及是否签到
            If name=arrayRet3[ii-2][0]   //如果找到了对应的名字
                If arrayRet3[ii-2][2]=1
                    qq_re("##,你今天已经签到过啦!明天再来吧!~~~",name)
                mingzibiaoshi=1
                Break
            ElseIf arrayRet3[ii-2][2]=0
                shengyuluobo= CInt(arrayRet3[ii-2][1])   //剩余萝卜
                suijiluobo=CInt(Excel.ReadCell(objExcelWorkBook,sheet,"B11")) //随机萝卜
                suijiluobo22=Excel.ReadCell(objExcelWorkBook,sheet,"B13"//随机萝卜
                Excel.WriteCell(objExcelWorkBook,sheet,"G"&ii,"1",False)  //更改签到标识
                Excel.WriteCell(objExcelWorkBook,sheet,"F"&ii,shengyuluobo+suijiluobo,False)  //添加剩余的萝卜
                qq_re("##,签到成功!"&suijiluobo22&"本次获取了"&suijiluobo&"个萝卜!剩余的萝卜是"&shengyuluobo+suijiluobo,name)
                mingzibiaoshi=1
                Break
            End If
        End If
    Next
    If mingzibiaoshi=0
        suijiluobo=CInt(Excel.ReadCell(objExcelWorkBook,sheet,"B11")) //随机萝卜
        suijiluobo22=Excel.ReadCell(objExcelWorkBook,sheet,"B13"//随机萝卜
        Excel.WriteCell(objExcelWorkBook,sheet,"E"&iRet3+1,name,False)  //添加名字
        Excel.WriteCell(objExcelWorkBook,sheet,"F"&iRet3+1,suijiluobo,False)  //添加萝卜数量
        Excel.WriteCell(objExcelWorkBook,sheet,"G"&iRet3+1,"1",False)  //更改签到标识
        suijiluobo = CInt(suijiluobo)
        qq_re("##,签到成功!"&suijiluobo22&"本次获取了"&suijiluobo&"个萝卜!剩余的萝卜是"&suijiluobo,name)
    End If
End Function

//QQ回复(文本,数据库行数,搜索类型(0一样,1匹配))
Function qq_re(sRet_Q,name)
    sRet_Q = Replace(sRet_Q,"##",name,False)
    Clipboard.SetText(sRet_Q)
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"V",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"uia","bClickBeforeInput":False})
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"Enter",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"uia","bClickBeforeInput":False})
End Function
//QQ回复图片
Function qq_rem(sRet_Q)
    Clipboard.SetImage(sRet_Q)  
    Excel.WriteCell(objExcelWorkBook,"Sheet1","D1","",False)
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"V",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"simulate","bClickBeforeInput":False})
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"Enter",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"uia","bClickBeforeInput":False})
End Function
//QQ回复文本+图片
Function qq_retm(arrayRet22,name,sheet)
    arrayRet22 = Replace(arrayRet22,"##",name,False)
    Clipboard.SetText(arrayRet22)
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"V",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"uia","bClickBeforeInput":False})
    SunExcel.Copy("智障机器人的智障回复.xlsx",sheet,"V22:AA25")
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"V",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"simulate","bClickBeforeInput":False})
    #icon("@res:hm6p79c9-i5u7-o525-74sq-qd1n6nm7rsij.png")
    Keyboard.PressKey({"wnd":[{"app":"QQ","cls":"TXGuiFoundation","title":qunmingcheng}],"ctrl":[{"role":"ROLE_SYSTEM_TEXT","name":"输入"}]},"Enter",0,10000,{"bContinueOnError":False,"iDelayAfter":0,"iDelayBefore":0,"bSetForeground":False,"sKeyModifiers":["Ctrl"],"sSimulate":"uia","bClickBeforeInput":False})
End Function


最新回复 (2)
  • mouhao 4月前
    2
    谢谢分享  学习一下,请问PC端需要发送消息给指定QQ群,整个操作都只能靠模拟操作吗?
  • 驿站工作室 1月前
    3
    为啥要获取qq号,直接回复不就好了吗
返回
发新帖