mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add telegram bot
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
|
||||
use App\Repositories\ToolRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Telegram\Bot\Api;
|
||||
use Telegram\Bot\Commands\HelpCommand;
|
||||
|
||||
class ToolController extends Controller
|
||||
{
|
||||
@@ -22,9 +24,42 @@ class ToolController extends Controller
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
public function tgBot(): string
|
||||
{
|
||||
$token = "xxxxxx";
|
||||
$telegram = new Api($token);
|
||||
$commandHelp = new HelpCommand();
|
||||
$commandBind = new TgCommandBind();
|
||||
$telegram->addCommand($commandHelp);
|
||||
$telegram->addCommand($commandBind);
|
||||
$update = $telegram->commandsHandler(true);
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
public function test(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
$token = "xxxxxx";
|
||||
$telegram = new Api($token);
|
||||
// $response = $telegram->getMe();
|
||||
// $response = $telegram->sendMessage([
|
||||
// "chat_id" => "-4170177008",
|
||||
// "text" => "Comes from xiaomlove!",
|
||||
// ]);
|
||||
|
||||
$commandHelp = new HelpCommand();
|
||||
$commandBind = new TgCommandBind();
|
||||
|
||||
$commands = [
|
||||
['command' => $commandHelp->getName(), 'description' => $commandHelp->getDescription()],
|
||||
['command' => $commandBind->getName(), 'description' => $commandBind->getDescription()],
|
||||
];
|
||||
$response = $telegram->setMyCommands([
|
||||
"commands" => json_encode($commands)
|
||||
]);
|
||||
// $response = $telegram->setWebhook(['url' => 'https://dev.nexusphp.org/nexusphp-tgbot/webhook']);
|
||||
|
||||
// $response = $telegram->getWebhookUpdate();
|
||||
dd($response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
"geoip2/geoip2": "~2.0",
|
||||
"hashids/hashids": "^4.1",
|
||||
"imdbphp/imdbphp": "^7.0",
|
||||
"irazasyed/telegram-bot-sdk": "^3.11",
|
||||
"laravel/framework": "9.52.4",
|
||||
"laravel/octane": "^1.2",
|
||||
"laravel/passport": "^11.10",
|
||||
|
||||
86
composer.lock
generated
86
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f42bf13488c7529904a43a89194212e9",
|
||||
"content-hash": "2b89de67bf5d41d008100e25d21303b0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/laravel-money",
|
||||
@@ -3006,6 +3006,90 @@
|
||||
},
|
||||
"time": "2023-01-07T18:55:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "irazasyed/telegram-bot-sdk",
|
||||
"version": "v3.11.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/irazasyed/telegram-bot-sdk.git",
|
||||
"reference": "e0e399e0452acdd0ba67bfe859737df7a5916f1f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/irazasyed/telegram-bot-sdk/zipball/e0e399e0452acdd0ba67bfe859737df7a5916f1f",
|
||||
"reference": "e0e399e0452acdd0ba67bfe859737df7a5916f1f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/guzzle": "^7.4.5",
|
||||
"guzzlehttp/psr7": "^2.4",
|
||||
"illuminate/support": "9 - 10",
|
||||
"league/event": "^2.2 || ^3.0",
|
||||
"php": ">=8.0",
|
||||
"psr/container": "^2.0",
|
||||
"psr/event-dispatcher": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"irazasyed/docgen": "^0.2",
|
||||
"pestphp/pest": "^1.22",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"phpspec/prophecy": "^1.17",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"rector/rector": "^0.15.21"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/container": "Hold dependencies to be injected in commands constructors",
|
||||
"irazasyed/larasupport": "Allows you to use any Laravel Package in Lumen by adding support!"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"Telegram": "Telegram\\Bot\\Laravel\\Facades\\Telegram"
|
||||
},
|
||||
"providers": [
|
||||
"Telegram\\Bot\\Laravel\\TelegramServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Telegram\\Bot\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Irfaq Syed",
|
||||
"email": "github@lukonet.net",
|
||||
"homepage": "https://github.com/irazasyed"
|
||||
}
|
||||
],
|
||||
"description": "The Unofficial Telegram Bot API PHP SDK",
|
||||
"homepage": "https://github.com/irazasyed/telegram-bot-sdk",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"laravel telegram",
|
||||
"telegram",
|
||||
"telegram bot",
|
||||
"telegram bot api",
|
||||
"telegram php",
|
||||
"telegram sdk"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/irazasyed/telegram-bot-sdk/issues",
|
||||
"source": "https://github.com/irazasyed/telegram-bot-sdk/tree/v3.11.0"
|
||||
},
|
||||
"time": "2023-04-15T11:23:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laminas/laminas-diactoros",
|
||||
"version": "2.24.0",
|
||||
|
||||
Reference in New Issue
Block a user