我正在尝试将 python 连接到我的英雄联盟聊天(巴西服务器)界面,以尝试对 ping 等运行一些自动响应。但我没有找到成功。这是我在 win32 上的 python Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] 中运行的代码。我在我的代码中使用我的用户名和密码。
import xmpp
conn = xmpp.Client("pvp.net")
if not conn.connect(server=("br.chat.si.riotgames.com", 5223)):
print ("connect failed.")
exit()
if not conn.auth("USER", "AIR_" + "PASSWORD", "xiff"):
print ("auth failed.")
exit()
这些是我得到的错误
> Invalid debugflag given: always Invalid debugflag given: nodebuilder
> DEBUG: DEBUG: Debug created for
> C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\client.py
> DEBUG: flags defined: always,nodebuilder DEBUG: socket start
> Plugging <xmpp.transports.TCPsocket object at 0x000002529F9F0DC8> into
> <xmpp.client.Client object at 0x000002529F8DD3C8> DEBUG: socket
> warn Could not load one of the supported DNS libraries (dnspython or
> pydns). SRV records will not be queried and you may need to set custom
> hostname/port for some servers to be accessible.\n DEBUG: socket
> start Successfully connected to remote host
> ('br.chat.si.riotgames.com', 5223) DEBUG: tls start Plugging
> <xmpp.transports.TLS object at 0x000002529FDCB248> into
> <xmpp.client.Client object at 0x000002529F8DD3C8> DEBUG: dispatcher
> start Plugging <xmpp.dispatcher.Dispatcher object at
> 0x000002529FDE1948> into <xmpp.client.Client object at
> 0x000002529F8DD3C8> DEBUG: dispatcher info Registering namespace
> "unknown" DEBUG: dispatcher info Registering protocol "unknown" as
> <class 'xmpp.protocol.Protocol'>(unknown) DEBUG: dispatcher info
> Registering protocol "default" as <class
> 'xmpp.protocol.Protocol'>(unknown) DEBUG: dispatcher info
> Registering namespace "http://etherx.jabber.org/streams" DEBUG:
> dispatcher info Registering protocol "unknown" as <class
> 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) DEBUG:
> dispatcher info Registering protocol "default" as <class
> 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) DEBUG:
> dispatcher info Registering namespace "jabber:client" DEBUG:
> dispatcher info Registering protocol "unknown" as <class
> 'xmpp.protocol.Protocol'>(jabber:client) DEBUG: dispatcher info
> Registering protocol "default" as <class
> 'xmpp.protocol.Protocol'>(jabber:client) DEBUG: dispatcher info
> Registering protocol "iq" as <class 'xmpp.protocol.Iq'>(jabber:client)
> DEBUG: dispatcher info Registering protocol "presence" as <class
> 'xmpp.protocol.Presence'>(jabber:client) DEBUG: dispatcher info
> Registering protocol "message" as <class
> 'xmpp.protocol.Message'>(jabber:client) DEBUG: dispatcher info
> Registering handler <bound method Dispatcher.streamErrorHandler of
> <xmpp.dispatcher.Dispatcher object at 0x000002529FDE1948>> for "error"
> type-> ns->(http://etherx.jabber.org/streams) DEBUG: dispatcher warn
> Registering protocol "error" as <class
> 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) DEBUG:
> socket sent <?xml version='1.0'?> <stream:stream
> xmlns="jabber:client" version="1.0"
> xmlns:stream="http://etherx.jabber.org/streams" to="pvp.net" > DEBUG:
> socket warn SSL_WANT_READ while receiving data, asking for a
> retry DEBUG: socket got <?xml version='1.0'?> <stream:stream
> xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'
> id='1475788316' from='br1.pvp.net'> <stream:error> <host-unknown
> xmlns='urn:ietf:params:xml:ns:xmpp-streams'/> </stream:error>
> </stream:stream> DEBUG: dispatcher ok Got
> http://etherx.jabber.org/streams/error stanza DEBUG: dispatcher ok
> Dispatching error stanza with type->
> props->['urn:ietf:params:xml:ns:xmpp-streams'] id->None Traceback
> (most recent call last): File
> "C:/Users/caioh/PycharmProjects/ProjectBadBot/test,py", line 4, in
> <module>
> if not conn.connect(server=("br.chat.si.riotgames.com", 5223)): File
> "C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\client.py",
> line 203, in connect File
> "C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\client.py",
> line 187, in connect File
> "C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\dispatcher.py",
> line 126, in Process File
> "C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\dispatcher.py",
> line 304, in dispatch File
> "C:\Users\caioh\PycharmProjects\ProjectBadBot\venv\lib\site-packages\xmpppy-0.6.1-py3.7.egg\xmpp\dispatcher.py",
> line 216, in streamErrorHandler xmpp.protocol.HostUnknown:
> ('host-unknown', '')
>
> Process finished with exit code 1
我对python相当陌生,我想知道是否有更简单的方法可以做到这一点,也许尝试直接通过客户端连接?我对R更熟悉,有没有更简单的方法可以做到这一点?