Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientgetnamefromuid with clientquery #85

Open
ghost opened this issue Jun 27, 2019 · 8 comments
Open

clientgetnamefromuid with clientquery #85

ghost opened this issue Jun 27, 2019 · 8 comments

Comments

@ghost
Copy link

ghost commented Jun 27, 2019

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

@ghost ghost changed the title event= clientgetnamefromuid with clientquery Jun 27, 2019
@ghost
Copy link
Author

ghost commented Jun 28, 2019

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

@whookie
Copy link

whookie commented Jun 28, 2019

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.

@ghost
Copy link
Author

ghost commented Jun 28, 2019

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?

@whookie
Copy link

whookie commented Jun 28, 2019

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

@ghost
Copy link
Author

ghost commented Jun 28, 2019

(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!

@whookie
Copy link

whookie commented Jun 28, 2019

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

@ghost
Copy link
Author

ghost commented Jul 5, 2019

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 :)

@whookie
Copy link

whookie commented Jul 5, 2019

Sure, just continue whenever.
I'll play around with the cq in the mean time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant