我有问题。我有以下代码:
import ts3
import time
with ts3.query.TS3Connection("185.201.114.62") as ts3conn:
ts3conn.login(client_login_name="serveradmin", client_login_password="password")
ts3conn.use(sid=1)
ts3conn.send_keepalive()
for client in ts3conn.clientlist():
for cm in ts3conn.clientgetuidfromclid(clid=client["clid"]):
#print(cm["cluid"])
ts3conn.sendtextmessage(targetmode=1, target=cm["cluid"], msg="test")
如果我执行代码,我会得到:
Traceback (most recent call last):
File "C:/Users/kacpe/PycharmProjects/ts3bot/main.py", line 12, in <module>
ts3conn.sendtextmessage(targetmode=1, target=cm["cluid"], msg="test")
File "C:\Users\kacpe\.virtualenvs\ts3bot\lib\site-packages\ts3\commands.py", line 2909, in sendtextmessage
return self._return_proxy("sendtextmessage", cparams, uparams, options)
File "C:\Users\kacpe\.virtualenvs\ts3bot\lib\site-packages\ts3\query.py", line 469, in _return_proxy
self, command, common_parameters, unique_parameters, options)
File "C:\Users\kacpe\.virtualenvs\ts3bot\lib\site-packages\ts3\query.py", line 446, in send
return self._wait_for_resp(timeout=timeout)
File "C:\Users\kacpe\.virtualenvs\ts3bot\lib\site-packages\ts3\query.py", line 383, in _wait_for_resp
raise TS3QueryError(resp)
ts3.query.TS3QueryError: error id 1540: convert error
如果我将targetmode设置为2(将消息发送到频道),则代码可以正常发送。