Author Topic: cronjob to set away/offline at a certain time  (Read 5487 times)

0 Members and 1 Guest are viewing this topic.

Bert

  • Full Member
  • ***
  • Posts: 13
cronjob to set away/offline at a certain time
« on: January 29, 2018, 03:04:09 PM »
We currently happily use Mibew on several of our websites.

To make sure we don't accidentally leave the chat Available outside business hours, I would like to add a cronjob to automatically set the chat to Away/Offline.
I'm looking for which SQL query to use.

I've already tried using...

Code: [Select]
UPDATE `operator` SET idisabled=1
...but this doesn't seem to have the intended effect.
(In fact, it somehow made it impossible for me to close the chat manually...)

Which query can I run to automatically close the chat?

faf

  • Mibew Staff Member
  • Native
  • *****
  • Posts: 950
    • Mibew Messenger
Re: cronjob to set away/offline at a certain time
« Reply #1 on: January 29, 2018, 04:52:44 PM »
To mess with the system on its low level is not the best way to do the job.

However, one can take a look on this function as a starting point.

Bert

  • Full Member
  • ***
  • Posts: 13
Re: cronjob to set away/offline at a certain time
« Reply #2 on: January 30, 2018, 08:31:20 AM »
To mess with the system on its low level is not the best way to do the job.

Hm, good point.

However, one can take a look on this function as a starting point.

Are you sure that function is in use, I don't see any calls to it in the code.
I think maybe I need to use notify_operator_alive()?

[Edit:]
Maybe this is a bit closer?
Code: [Select]
UPDATE operator SET istatus=1,idisabled=1,dtmlastvisited=UNIX_TIMESTAMP(NOW());
« Last Edit: January 30, 2018, 08:42:19 AM by Bert »

faf

  • Mibew Staff Member
  • Native
  • *****
  • Posts: 950
    • Mibew Messenger
Re: cronjob to set away/offline at a certain time
« Reply #3 on: January 30, 2018, 12:53:17 PM »
However, one can take a look on this function as a starting point.

Are you sure that function is in use, I don't see any calls to it in the code.

Yes, I'm sure;D

It's a part of the core Client-Server interaction for the Users application. It's called during the special RPC-like interaction between the client and the server. However, it's a little bit complicated matter that can be hard to explain. If you really want to understand it you should start with the docs: https://docs.mibew.org/development/core-architecture.html

I think maybe I need to use notify_operator_alive()?

Yes, probably you could write a plugin that utilizes the CRON_RUN event and calls this function.

[Edit:]
Maybe this is a bit closer?
Code: [Select]
UPDATE operator SET istatus=1,idisabled=1,dtmlastvisited=UNIX_TIMESTAMP(NOW());

To begin with, you don't need idisabled. You don't have to disable an operator, just alter the status. And as it was written before, bare SQL-requests is a bad idea.

Bert

  • Full Member
  • ***
  • Posts: 13
Re: cronjob to set away/offline at a certain time
« Reply #4 on: January 30, 2018, 02:27:37 PM »
Thanks for the feedback.

In the end, I decided to go for a different approach.
I now hide the mibew button itself outside business hours.
So, during the day, they can on-/offline the button...
...and when we're closed visitors don't see the button, which means it's not an issue if an employee accidentally leaves the chat online.