clientgetnamefromuid with clientquery
Opened this issue · 8 comments
Hey, really really new to Python and programming in general but I thought this would be a fun project for the summer holidays.
I'm trying to get client names from their Unique IDs
print(ts3conn.exec_("clientgetnamefromuid", cluid=str(row[4])))
but I keep getting <ts3.response.TS3QueryResponse object at 0x09A569D0>
How do I turn this into normal text?
Using clientquery not serverquery if that's of any interest
Edit: In other words I want to get a users current Name by from their Unique ID
This is my script right now
ts3conn.exec_("clientnotifyregister", schandlerid=1, event="notifyclientnamefromuid") ts3conn.exec_("clientgetnamefromuid", cluid="hIj5mUvCCyTId6ihm1vdc/j2yTU=")
In my putty window I get clear text, name, id and everything else but in my document I get nothing else but bytes returned
So I looked it up:
You have two problems here.
(1) The response you are getting: <ts3.response.TS3QueryResponse object at 0x09A569D0>
This is because you are trying to print an object that doesnt support a "to string" method (__repr__()
in python). So it prints a default string. This default string is the object type and the object ID (not sure if ID or memory address, but doesnt matter right now). It is built like this:
<package.subclass.[...].class at [ID or address]>
(the [] are placeholders)
(2) The examples in the readme file touches this very well:
You can either execute a command without getting a response, or you can actually query data.
To just send a request without caring about the response, you can just use what you have been using:
ts3conn.exec_(...)
If you want to query data, you have to use another method:
ts3conn.query(...)
But you are not done with just the ts3conn.query(...)
call.
Do actually get the data, you need to call the all()
method. You can also use first()
, I don't know exactly how many exist here, just look it up in the documentation somewhere.
What you want to do:
ts3conn.exec_("clientnotifyregister", schandlerid=1, event="notifyclientnamefromuid")
and myResult = ts3conn.query("clientgetnamefromuid", cluid="hIj5mUvCCyTId6ihm1vdc/j2yTU=").all()
None of this code is tested by the way, so please correct me if I'm wrong.
Also this is for ServerQuery, but clientquery should work similar I guess.
Thanks for your answer!
That didn't seem to work, just like before Putty spits out the name of the unique ID but my console keep giving me []
I've tried
ts3conn.query("channelvariable", cid=channelid).first()
ts3conn.query("clientlist").all()
Which works great, maybe this whole event stuff doesn't work for clientquery?
That is better, at least now it gives you the correct return type.
Some things you can take a look at:
(1) Is your putty connecting to Client Query instead of Server Query?
(2) Do you have different permissions? Meaning, do you login with putty with the same credentials as in your program? (If not, check the permissions, maybe you are not allowed to see users)
I will update this post if I can think of more reasons
(1) Yeah with the same auth key and everything
(2) Yeah the same permissions since I'm connecting to the same user
Really appreciate you taking your time helping me with this!
If you want to discuss this more hands-on, you can give me your server address and I can join tomorrow (today).
As it is mostly the case in programming, I am sure this is a simple solution to a complicated problem or a complicated solution to a simple problem :P
Hey sorry for not responding for a while, been hella busy lately. I'll be back at my PC in a week if you are still up for helping me :)
Sure, just continue whenever.
I'll play around with the cq in the mean time