首次提交 Laravel 專案
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_KEY'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\tg_group;
|
||||
use App\Models\tg_Msg;
|
||||
use App\Services\TgApi;
|
||||
use App\Services\UserFun;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TgController extends Controller
|
||||
{
|
||||
public function Msg($token,Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$data='{"token": "7710672705:AAEX1RWhBoLA2L5EZuTLajQ---tRjahNr9w", "update_id": 250041634, "message_date": 1746524847, "message_text": "@winchen1688 +2000", "message_chat_id": -4661252768, "message_from_id": 7559940376, "message_chat_type": "group", "message_chat_title": "一路发测试群", "message_message_id": 5, "message_from_is_bot": false, "message_from_username": "xiongia", "message_from_last_name": "xiong", "message_entities_0_type": "mention", "message_from_first_name": "ab ni", "message_entities_0_length": 12, "message_entities_0_offset": 0, "message_chat_all_members_are_administrators": true, "message_chat_accepted_gift_types_unique_gifts": false, "message_chat_accepted_gift_types_limited_gifts": false, "message_chat_accepted_gift_types_unlimited_gifts": false, "message_chat_accepted_gift_types_premium_subscription": false}';
|
||||
|
||||
$msg=UserFun::Json2Arr($data); //将JSON转换成一維扁平陣列
|
||||
$user=TgApi::GetChatMember($msg);
|
||||
dd($user);
|
||||
$msg['token']=$token;
|
||||
$tgmsg=tg_Msg::storeFromWebhookJson($msg);
|
||||
$chatResponse=TgApi::GetChatInfo($msg);
|
||||
if($chatResponse['ok'] && isset($chatResponse['result']['id'])){
|
||||
$chatData = $chatResponse['result'];
|
||||
$chatModel = tg_group::updateOrCreateFromTelegram($chatData);
|
||||
return ['ok' => true, 'chat_id' => $chatModel->chat_id];
|
||||
} else {
|
||||
return ['ok' => false, 'error' => '无法取得群资料', 'raw' => $chatResponse];
|
||||
}
|
||||
// $tg_group=tg_group::updateOrCreateFromTelegram($chat_id);
|
||||
// $chat=UserFun::Json2Arr($chat_id);
|
||||
// dd($chat_id);
|
||||
// return $tg_group;
|
||||
|
||||
// return $tgmsg;
|
||||
// return response()->json(['status' => 'ok']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tg_bot', function (Blueprint $table) {
|
||||
$table->increments('id'); // 主键 + AUTO_INCREMENT
|
||||
$table->string('bot_id')->nullable()->comment('bot_id');
|
||||
$table->string('bot_token')->nullable()->comment('bot_oken');
|
||||
$table->string('bot_username')->nullable()->comment('bot名称');
|
||||
$table->string('subjection_username')->nullable()->comment('隶属飞机用户');
|
||||
$table->string('subjection_mobile')->nullable()->comment('隶属飞机用户手机号');
|
||||
$table->text('webhook')->nullable()->comment('webhook_url');
|
||||
$table->text('memo')->nullable()->comment('备注说明');
|
||||
$table->timestamp('created_at')->useCurrent()->nullable();
|
||||
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
$table->comment('机器人资料');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tg_bot');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user