core icon indicating copy to clipboard operation
core copied to clipboard

How to Get Answer From command /survey ?

Open reactmorelab opened this issue 7 years ago • 2 comments

hi, can you please give an example , how to make the results from command /survey sent to the admin bot ?

reactmorelab avatar Nov 22 '19 22:11 reactmorelab

I assume you're saving all data to the $notes variable? After the last stage, when the survey command is finished, you can simply send whatever data from $notes that you like to to the admin user.

Have a look at how this is done in the example: https://github.com/php-telegram-bot/example-bot/blob/cbaec2e66519da9bc01b7ca97e4b0c9666d7bb84/Commands/SurveyCommand.php#L241

noplanman avatar Nov 23 '19 10:11 noplanman

Like this sir ? make two result ? $this->conversation->update(); $out_text = '/Survey result:' . PHP_EOL; unset($notes['state']); foreach ($notes as $k => $v) { $out_text .= PHP_EOL . ucfirst($k) . ': ' . $v; }

            $data['photo']        = $notes['photo_id'];
            $data['reply_markup'] = Keyboard::remove(['selective' => true]);
            $data['caption']      = $out_text;
            $this->conversation->stop();         
            
           
            $result = Request::sendPhoto($data);
            $result = Request::sendPhoto([
                    'chat_id' => '$admin_user',
                    'photo' => $data,
                ]);
            break;

reactmorelab avatar Nov 23 '19 13:11 reactmorelab