Skip to content

Buttons for a bot #52

Open
Open
@BeheniyKys

Description

@BeheniyKys

Good afternoon, I beg you to help me, is it possible to somehow attach the code to the button, I'm new to php and according to your guide I can't figure out how to make a button with this function. I would be very grateful for help

/**
 * User "/newfollowup" command
 */
class NewfollowupCommand extends UserCommand
{
    /**
     * @var string
     */
    protected $name = 'newfollowup';

    /**
     * @var string
     */
    protected $description = 'Add a new followup to a ticket on GLPI via TelegramBot.';

    /**
     * @var string
     */
    protected $usage = '/newfollowup <ticket_id>**<text>';

    /**
     * @var string
     */
    protected $version = '1.0.0';

    /**
     * Command execute method
     *
     * @return \Longman\TelegramBot\Entities\ServerResponse
     * @throws \Longman\TelegramBot\Exception\TelegramException
     */
    public function execute()
    {
        $message   = $this->getMessage();
        $chat_id   = $message->getChat()->getId();
        $user_chat = $message->getFrom()->getUsername();
        $text      = trim($message->getText(true));
        
        $response = \PluginTelegrambotTicket::newFollowup($chat_id, $user_chat, $text);
        
        if(!$response){
            $response = 'Command usage: ' . $this->getUsage();
        }
        
        $data = [
            'chat_id' => $chat_id,
            'text'    => $response,
        ];

        return Request::sendMessage($data);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions