skip to Main Content

I want to send message to user after 2 minute he has clicked an callback query and execute database automatically after that 2 minute .

2

Answers


  1. You can create a table called jobs and set a cron job to run every minute to check if there is any job to run. So you create a job for doing what you want and consider a column named runs_at.

    id command runs_at
    1 { "class_name": "DatabaseQueryJob", "parameters": { ... } } 2022-06-15 15:22:00

    You have a class for running database queries and save what you need in parameters. Delete executed jobs from table and that’s it.

    I hope this idea solves your problem and let me know if I misunderstood you.

    Login or Signup to reply.
  2. Use sleep function

    switch($callbackdata){  ## Or whetever you named it
        case 'example':
            sleep(120);
            sendMessage($id, "Message");
            ## CODE TO BE EXECUTED
            break;
        case 'secondexample':
            .....
            break;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search