• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN Getting right idle time of a client

Status
Not open for further replies.

Nicer

Member
Hello there, I have a problem with getting client's idle time. Well the problem is that I'm getting some random values instead of getting right idle time.

PHP:
    sinusbot.on('chat', function (ev) {
        var backend = require('backend');
        var client = backend.getClientByUniqueID(ev.clientUid);
sinusbot.chatPrivate(client.id(), client.getIdleTime());

This code returns a number which seems to be increasing every second. (Even when my idle time got back to ~0 s after typing)

SinusBot 0.9.18-8499d2c; 64bit Win version; 6Gigs of ram; laptop i5
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
The old scripting engine are all Javascript functions which are using the sinusbot object. E.g. sinusbot.chatChannel(). The new engine uses the oop node require' programming style. I hope i could help ;)
 

Nicer

Member
Even after converting it to the new engine
PHP:
ev.client.chat(ev.client.getIdleTime());
Still grows up. Don't know what's wrong with it.
 

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Even after converting it to the new engine
PHP:
ev.client.chat(ev.client.getIdleTime());
Still grows up. Don't know what's wrong with it.
the idle time is returned in milliseconds and only gets updated about every 2 minutes
 

irgendwr

no longer active, "retired" staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Is there any way to increase the refresh time?
No but you could code a workaround yourself. You would have to record the last time a client triggered an event and conclude when the idle time is off.
But why would you really need an idle time that accurate?
 

Nicer

Member
No but you could code a workaround yourself. You would have to record the last time a client triggered an event and conclude when the idle time is off.
But why would you really need an idle time that accurate?
I'm making script that will move to the guy who typed '!switch' if idle time of clients that are in room with bot is higher than limit in config.
 

Nicer

Member
I would really appreciate some option in config for changing client info refresh. It would help making my dream real :D
 

Diesmon

Tuetchen Dominator
is awesome!
Contributor
Insider
I still don't get your "script-idea". Since idle times says nothing about the activity in my eyes. I mean sometimes we aren't talking for half an hour in our TS channel and just listening to music or so and other times we are playing something and talking all the time. But well, if you have that idea in mind, go for it. And for the refresh rate problem I guess you need to wait for an update which changes that (which will maybe never happen) or do like irgendwer said and build your own idle time in the script.
 

Murks1

Member
I tried to code a afk mover, which can move you back, but it is not worth with 2 min delay.

Time is in milliseconds and counting higher with calculatet data.
 
Status
Not open for further replies.
Top