gioco-plus/grabber-log

There is no license information available for the latest version (v2.5.0) of this package.

Maintainers

Package info

github.com/gioco-play/grabber-log

pkg:composer/gioco-plus/grabber-log

Transparency log

Statistics

Installs: 13 373

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.5.0 2026-07-03 04:00 UTC

README

初始化

use GiocoPlus\GrabberLog\GrabberLog;
/**
 * GrabberLog constructor.
 * @param string $vendorCode
 * @param array $options
 * @throws \Exception
 */
 
$grabberLog = new GrabberLog($vendorCode, $options);

參數說明

參數 類型 說明
$vendorCode string 遊戲商代碼
$options array 請看 options 說明

$options

參數皆為選填

參數 類型 說明
agent string 代理
record_type string 注單類型
operator_code string 營商代碼
fail_count_notify int 錯誤次數達到時發送通知,通知環境請設定 SERVICE_ENV (未設定預設為 unknown)

環境變數設定

若要啟用第三方平台通知,請在 .env 中設定以下變數:

# 環境標記
SERVICE_ENV=local

# Discord 通知 (選填)
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...

# Telegram 通知 (選填)
TELEGRAM_BOT_TOKEN=123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ
TELEGRAM_CHAT_ID=-100123456789
TELEGRAM_TOPIC_ID=12  # Super Group 子主題/討論串 ID (選填)

# Line Notify 通知 (選填)
LINE_NOTIFY_ACCESS_TOKEN=your_line_notify_token

紀錄開始

$grabberLog->running($start, $extraParams);

參數說明

參數 類型 說明
$start string 紀錄開始 id or date
$extraParams array 紀錄額外搜尋條件,若有明確的結束時間陣列 key 請使用 end

紀錄結束 (成功)

$grabberLog->complete($extraParams);

參數說明

參數 類型 說明
$extraParams array 提供完成時需額外紀錄

紀錄結束 (失敗)

$grabberLog->fail($extraParams, $options);

參數說明

參數 類型 說明
$extraParams array 提供完成時需額外紀錄
$options array 請看 options 說明

$extraParams

參數皆為選填

參數 類型 說明
error_message string (500) 若有此參數,將在發送通知(Telegram / Discord / Line Notify)時,將錯誤訊息一併送出

$options

參數皆為選填

參數 類型 說明
maintain bool 是否維護,此參數為 true 時,則不會計算失敗次數及發送通知。

額外功能

取得最後一筆 grabber log

$grabberLog->lastLog($filter);

參數說明

參數 類型 說明
$filter array 額外搜尋條件

取得下次抓取時間

僅適用 log 內有 startend

nextGrabber 返回 Carbon 物件

nextGrabberTime 返回 10 位 timestamp

['start' => $startTime, 'end' => $endTime] = $grabberLog->nextGrabberTime(
                    $pastMinutes,
                    $longTimeRang,
                    ['bufferNowMin' => $bufferMin]
                );

參數說明

參數 類型 說明
$past_minutes int 過去分鐘數
$longTimeRang int 最長時間範圍 (單位 min)
$options array 請看 options 說明

$options

參數 類型 說明
bufferNowMin int 距離現在時間 int (單位 min),影響結束時間(end)
coverTimeRang int 包含上次抓取時間 (單位 min)
lastLogFilter array 最後一條紀錄 filter