gioco-plus / grabber-log
There is no license information available for the latest version (v2.5.0) of this package.
v2.5.0
2026-07-03 04:00 UTC
Requires
- php: >=7.2
- gioco-plus/prism-plus: dev-master || >=1
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 內有
start、end
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 |