txodds supervisor for markets with lastcall

This commit is contained in:
salam committed 2026-01-14 17:43:04 +01:00
1 parent 61a6971a64
commit 6978f8095c
19 files changed
+369 -215

No files matched your search

+1 -5
View File
@@ -5,7 +5,6 @@ namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
class TxOdds
{
@@ -15,11 +14,8 @@ class TxOdds
case 'Fixtures':
Fixtures::grap();
break;
case 'Odds':
Odds::grap();
break;
default:
Notice::note('prosses name does not exist', 'r', 1);
Odds::grap();
break;
}
}
+87 -135
View File
@@ -25,6 +25,8 @@ use App\Models\Element;
use App\Models\ElementGroup;
use App\Models\Event;
use App\Models\Group;
use App\Models\Supervisor;
use App\Models\TxoddsMarket;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -49,110 +51,18 @@ class Odds
Notice::note("Deleted: $info");
}
/*************************************************
* https://xml2.txodds.com/feed/odds_types.php
* BETTYPE IDS
0 3-WAY
1 2-WAY
3 POINTS
4 TOTALS
131073 MONEY LINE - Q1
65536 3-WAY HALF TIME
65540 TOTALS HALF TIME
65539 POINTS HALF TIME
131075 POINTS QUARTER TIME
131076 TOTALS QUARTER TIME
5242880 DOUBLE CHANCE
6291457 DRAW NO BET
11534337 GG/NG (both teams to score)
7340033 TO PROGRESS (to qualify)
Not used:
5 Asian
131072 3 WAY QUARTER TIME
262148 TOTALS OVER TIME
262147 POINTS OVER TIME
65537 2-WAY HALF TIME
327680 3-WAY 2ND HALF
327681 2-WAY 2ND HALF
327683 POINT 2ND HALF
327684 TOTALS 2ND HALF
1048577 GOAL / NO GOAL
2097153 ODD / EVEN
4194304 TOTAL GOALS
8388608 1X2 EURO HANDCIAP
9437188 TOTAL CORNERS
9502724 TOTAL CORNERS 1ST HALF
20971520 3-WAY CORNERS
28311555 HANDICAP SETS
28311556 TOTAL SETS
*************************************************/
switch (Nuh::$options['sport_id']) {
case 1:
/**
* 0 3-WAY
* 4 TOTALS
* 65536 3-WAY HALF TIME
* 65540 TOTALS HALF TIME
* 11534337 GG/NG (both teams to score)
* 5242880 DOUBLE CHANCE
* 7340033 TO PROGRESS (to qualify)
* 6291457 DRAW NO BET
*/
$markets = '0,4,65536,65540,11534337,5242880,7340033,6291457';
break;
case 2:
/**
* 0 3-WAY
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '0,1,3,4,131076,131075';
break;
case 3:
/**
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 65539 POINTS HALF TIME
* 65540 TOTALS HALF TIME
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '1,3,4,65539,65540,131075,131076';
break;
case 5:
/**
* 1 2-WAY
* 131073 MONEY LINE - Q1
* 3 POINTS
* 4 TOTALS
*/
$markets = '1,3,4,131073';
break;
default:
Notice::note('sport not defined', 'r', 1);
break;
}
$txodds_markets_columns = [
1 => 'soccer',
2 => 'ice_hockey',
3 => 'basketball',
5 => 'tennis',
];
$res = TxoddsMarket::where($txodds_markets_columns[Nuh::$options['sport_id']], 1)->pluck('market_id', 'id')->toArray();
/*************************************************
* use_lastcall
*************************************************/
if (Nuh::$options['use_lastcall']) {
$lastcall = Nuh::$options['lastcall'] ? '&last='.Nuh::$options['lastcall'] : '';
}
$markets = '&ot='.implode(',', $res);
/*************************************************
* URL
@@ -162,75 +72,113 @@ class Odds
} else {
$AUTHTOKEN = 'ident=betaid2&passwd=Dy59vpRC';
}
$url = 'https://xml2.txodds.com/feed/odds/xml.php?'.$AUTHTOKEN.'&all_odds=2';
$_calls = [];
if (Nuh::$options['id']) {
$sport = '&spid='.Nuh::$options['sport_id'];
if (Nuh::$options['provider_id'] == 8) {
/*************************************************
* TXODDS MARKET LASTCALL
*************************************************/
if ($debug) {
Notice::note('TXOdds MARKET Lastcall', 'p');
}
$market = '&ot='.Nuh::$options['txodds_market_id'];
$lastcall = Nuh::$options['lastcall'] > time() - 600 ? '&last='.Nuh::$options['lastcall'] : '&last='.time() - 600;
$_calls[] = $url.$sport.$market.$lastcall;
} elseif (Nuh::$options['id']) {
/*************************************************
* BY ID
*************************************************/
if ($debug) {
Notice::note("BY ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* by specific ID
*/
$_calls[] = $url."&ot=$markets&peid=".Nuh::$options['id'];
$id = '&peid='.Nuh::$options['id'];
$_calls[] = $url.$markets.$id;
} elseif (Nuh::$options['g']) {
/*************************************************
* BY GROUP ID
*************************************************/
if ($debug) {
Notice::note("GROUP_ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* per group_id
* with from-to
*/
$from_to = '&days='.Nuh::$options['days_from'].','.Nuh::$options['days_to'];
$groupids = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->groupBy('group_id')->pluck('group_id');
foreach ($groupids as $groupid) {
$_calls[] = $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&ot='.$markets.'&days='.Nuh::$options['days_from'].','.Nuh::$options['days_to'].'&pgid='.$groupid;
$_calls[] = $url.$markets.$from_to.'&pgid='.$groupid;
}
} elseif (Nuh::$options['t']) {
/*************************************************
* TODAY by ID
*************************************************/
if ($debug) {
Notice::note("TODAY \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* today
*/
$from = Carbon::now()->toDateTimeString();
$to = Carbon::now()->addDays(1)->toDateTimeString();
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>=', $from)->where('starttime', '<', $to)->pluck('id');
foreach ($res as $id) {
$_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&peid=".$id;
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} elseif (Nuh::$options['w']) {
/*************************************************
* ONE WEEK FROM NOW
*************************************************/
if ($debug) {
Notice::note("WEEK \nsport_id: ".Nuh::$options['sport_id'], 'p');
Notice::note("ONE WEEK FROM NOW \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* week from now
*/
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('id');
foreach ($res as $id) {
$_calls[] = $url."&ot=$markets&peid=".$id;
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} else {
} elseif (Nuh::$options['a']) {
/*************************************************
* ALL BY ID (reload)
*************************************************/
if ($debug) {
Notice::note("ALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* ALL by ID
*/
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id');
foreach ($res as $id) {
$_calls[] = $url."&ot=$markets&peid=".$id;
}
if ($debug) {
Notice::note("LASTCALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
/**
* WITH LASTCALL Parameter
* with from-to days
*/
$_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&days=".Nuh::$options['days_from'].','.Nuh::$options['days_to'].$lastcall;
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id');
foreach ($res as $id) {
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} else {
Notice::note('BASH PARAMETER MISSING [--t, --w, --g, --a, --id=]', 'r', 1);
}
/*************************************************
@@ -243,6 +191,10 @@ class Odds
$data = Xml::load($url);
if (Nuh::$options['provider_id'] == 8) {
Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => (int) $data['timestamp']]);
}
if ($debug) {
Notice::note('counter: '.count($_calls).'/'.$counter, 'g');
}
@@ -0,0 +1,97 @@
/*************************************************
* https://xml2.txodds.com/feed/odds_types.php
* BETTYPE IDS
0 3-WAY
1 2-WAY
3 POINTS
4 TOTALS
131073 MONEY LINE - Q1
65536 3-WAY HALF TIME
65540 TOTALS HALF TIME
65539 POINTS HALF TIME
131075 POINTS QUARTER TIME
131076 TOTALS QUARTER TIME
5242880 DOUBLE CHANCE
6291457 DRAW NO BET
11534337 GG/NG (both teams to score)
7340033 TO PROGRESS (to qualify)
Not used:
5 Asian
131072 3 WAY QUARTER TIME
262148 TOTALS OVER TIME
262147 POINTS OVER TIME
65537 2-WAY HALF TIME
327680 3-WAY 2ND HALF
327681 2-WAY 2ND HALF
327683 POINT 2ND HALF
327684 TOTALS 2ND HALF
1048577 GOAL / NO GOAL
2097153 ODD / EVEN
4194304 TOTAL GOALS
8388608 1X2 EURO HANDCIAP
9437188 TOTAL CORNERS
9502724 TOTAL CORNERS 1ST HALF
20971520 3-WAY CORNERS
28311555 HANDICAP SETS
28311556 TOTAL SETS
*************************************************/
switch (Nuh::$options['sport_id']) {
case 1:
/**
* 0 3-WAY
* 4 TOTALS
* 65536 3-WAY HALF TIME
* 65540 TOTALS HALF TIME
* 11534337 GG/NG (both teams to score)
* 5242880 DOUBLE CHANCE
* 7340033 TO PROGRESS (to qualify)
* 6291457 DRAW NO BET
*/
$markets = '0,4,65536,65540,11534337,5242880,7340033,6291457';
break;
case 2:
/**
* 0 3-WAY
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '0,1,3,4,131076,131075';
break;
case 3:
/**
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 65539 POINTS HALF TIME
* 65540 TOTALS HALF TIME
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '1,3,4,65539,65540,131075,131076';
break;
case 5:
/**
* 1 2-WAY
* 131073 MONEY LINE - Q1
* 3 POINTS
* 4 TOTALS
*/
$markets = '1,3,4,131073';
break;
default:
Notice::note('sport not defined', 'r', 1);
break;
}
+3 -5
View File
@@ -24,11 +24,7 @@ class Nuh extends Command
public static $collector = [];
public static $BETSAPI_TOKEN = '36152-aeTRNnZxSPUwGe';
protected $signature = 'nuh {process=help} {--id=0} {--f=} {--p} {--d} {--x} {--t} {--w} {--g} {--r} {--s} {--t} {--q}';
protected $description = 'Nuh';
protected $signature = 'nuh {process=help} {--id=0} {--f=} {--p} {--d} {--x} {--t} {--w} {--g} {--a} {--r} {--s} {--t} {--q}';
public function handle()
{
@@ -51,6 +47,7 @@ class Nuh extends Command
$txt .= '--d debug'.PHP_EOL;
$txt .= '--x generate supervisors'.PHP_EOL;
$txt .= '--t load today'.PHP_EOL;
$txt .= '--a all by id'.PHP_EOL;
$txt .= '--w laod this week (tx)'.PHP_EOL;
$txt .= '--g by minor groups (tx)'.PHP_EOL;
$txt .= '--r read data from file '.PHP_EOL;
@@ -80,6 +77,7 @@ class Nuh extends Command
switch (self::$options['provider_id']) {
case 1:
case 8:
TxOdds::switch();
break;
case 2:
@@ -15,6 +15,7 @@ class BettypesTable
{
return $table
->striped()
->recordAction(null)
->columns([
TextColumn::make('bettype_id')
->width('1rem')
@@ -42,7 +43,7 @@ class BettypesTable
->toArray()),
])
->recordActions([
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
}
@@ -15,6 +15,7 @@ class BookmakersTable
{
return $table
->striped()
->recordAction(null)
->columns([
TextColumn::make('name')
->searchable(),
@@ -38,7 +39,7 @@ class BookmakersTable
TernaryFilter::make('is_active')->default(true),
])
->recordActions([
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
}
@@ -18,6 +18,7 @@ class ClientsTable
{
return $table
->striped()
->recordAction(null)
->columns([
TextColumn::make('name'),
TextColumn::make('bookmaker')
@@ -48,7 +49,7 @@ class ClientsTable
->action(function ($record) {
AlarmGenerator::run($record);
}),
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
}
@@ -12,6 +12,7 @@ class CompetitionGroupsTable
public static function configure(Table $table): Table
{
return $table
->striped()
->columns([
IconColumn::make('sport.icon')
->label('')
@@ -34,10 +35,6 @@ class CompetitionGroupsTable
'MEDIUM' => 'MEDIUM',
'LOW' => 'LOW',
]),
])
->filters([
//
]);
}
}
@@ -49,6 +49,7 @@ class CountryResource extends Resource
{
return $table
->striped()
->recordAction(null)
->recordTitleAttribute('name')
->columns([
TextColumn::make('id')->searchable(),
@@ -78,7 +79,7 @@ class CountryResource extends Resource
->query(fn (Builder $query): Builder => $query->whereNull('icon')),
])
->recordActions([
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
@@ -12,12 +12,13 @@ class ProvidersTable
{
return $table
->striped()
->recordAction(null)
->columns([
TextColumn::make('id')->alignCenter()->badge(),
TextColumn::make('name'),
])
->recordActions([
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
}
@@ -17,9 +17,9 @@ class SupervisorForm
->relationship('provider', 'name')
->required()
->preload(),
// Select::make('sport_id')
// ->relationship('sport', 'name')
// ->nullable(),
Select::make('sport_id')
->relationship('sport', 'name')
->nullable(),
// TextInput::make('sleep')->default(30),
// TextInput::make('maxsconds')->label('Seconds till throwing an error')->default(1800),
@@ -2,12 +2,16 @@
namespace App\Filament\Resources\Supervisors\Tables;
use App\Filament\Resources\Supervisors\Pages\ListSupervisors;
use App\Models\Sport;
use App\Models\Supervisor;
use App\Models\TxoddsMarket;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\Layout\Split;
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\SelectColumn;
@@ -26,6 +30,7 @@ class SupervisorsTable
{
return $table
->striped()
->recordAction(null)
->poll('10s')
->columns([
Split::make([
@@ -33,12 +38,16 @@ class SupervisorsTable
TextColumn::make('provider.name')
->color(fn ($record): string => match ($record->provider_id) {
1 => 'danger',
8 => 'danger',
2 => 'success',
default => 'warning',
}),
Stack::make([
SelectColumn::make('name')
->disablePlaceholderSelection()
->hidden(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
})
->options(function ($record) {
switch ($record->provider_id) {
case 1:
@@ -60,50 +69,106 @@ class SupervisorsTable
'Betfair' => 'Betfair',
];
case 7:
/**
* functions for services
*/
return [
'Txodds Markets' => 'Txodds Markets',
];
default:
return [];
}
}),
SelectColumn::make('sport_id')
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id'))
->placeholder('All'),
SelectColumn::make('txodds_market_id')
->visible(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
})
->options(function ($record) {
switch ($record->sport_id) {
case 1:
return TxoddsMarket::where('soccer', 1)->pluck('name', 'market_id');
case 2:
return TxoddsMarket::where('ice_hockey', 1)->pluck('name', 'market_id');
case 3:
return TxoddsMarket::where('basketball', 1)->pluck('name', 'market_id');
case 5:
return TxoddsMarket::where('tennis', 1)->pluck('name', 'market_id');
}
})
->placeholder('All Markets'),
])->space(3),
Stack::make([
TextInputColumn::make('days_from')->prefix('Days Fm'),
TextInputColumn::make('days_to')->prefix('Days To'),
TextInputColumn::make('days_from')->prefix('Days Fm')
->hidden(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
}),
TextInputColumn::make('days_to')->prefix('Days To')
->hidden(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
}),
])->space(3),
Stack::make([
TextColumn::make('lastcall')
->prefix('Lastcall: ')
->badge()
->color(fn ($state): string => ($state > 0 && $state > time() - 300) ? 'success' : 'danger')
->dateTime()
->visible(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
}),
TextInputColumn::make('sleep')->prefix('Seep'),
TextInputColumn::make('commandline_options')->prefix('Bash'),
TextInputColumn::make('commandline_options')->prefix('Bash')
->hidden(function (ListSupervisors $livewire) {
return $livewire->tableFilters['provider_id']['value'] == 8;
}),
])->space(3),
ToggleColumn::make('use_lastcall')->label('Lastcall')->tooltip('Use last call parameter'),
// ToggleColumn::make('use_lastcall')->label('Lastcall')->tooltip('Use last call parameter'),
ToggleColumn::make('is_supervisor')->label('Super')->tooltip('Run as supervisor'),
ToggleColumn::make('is_active')->label('Active')->tooltip(('On/Off'))->onColor('success'),
TextColumn::make('runtime')->label('Run Time')->badge(),
ToggleColumn::make('is_active')->label('Active')->tooltip(('On/Off'))->onColor('success')->offColor('danger'),
TextColumn::make('runtime')->badge()->prefix('Runtime: '),
]),
])
->filters([
SelectFilter::make('provider_id')
->default(1)
->selectablePlaceholder(false)
->relationship('provider', 'name')
->label('Provider'),
SelectFilter::make('sport_id')
->default(1)
->relationship('sport', 'name')
->label('Sport'),
TernaryFilter::make('is_supervisor')->label('Run by supervisor'),
TernaryFilter::make('is_active'),
], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->recordActions([
EditAction::make()->hiddenLabel(),
DeleteAction::make()->hiddenLabel(),
])
->toolbarActions([
BulkActionGroup::make([
BulkAction::make('sleep')
->label('Sleep')
->icon('phosphor-timer')
->action(function (Collection $records, array $data): void {
foreach ($records as $record) {
Supervisor::where('id', '=', $record->id)
->update(
['sleep' => $data['sleep']]
);
}
})
->form([
TextInput::make('sleep')->hiddenLabel()->prefix('Sleep'),
]),
BulkAction::make('Switch On')
->icon('phosphor-play')
->action(function (Collection $records, array $data): void {
->action(function (Collection $records): void {
foreach ($records as $record) {
Supervisor::where('id', '=', $record->id)
->update(
@@ -113,7 +178,7 @@ class SupervisorsTable
}),
BulkAction::make('Switch Off')
->icon('phosphor-stop')
->action(function (Collection $records, array $data): void {
->action(function (Collection $records): void {
foreach ($records as $record) {
Supervisor::where('id', '=', $record->id)
->update(
@@ -121,6 +186,26 @@ class SupervisorsTable
);
}
}),
BulkAction::make('As supervisor')
->icon('phosphor-play')
->action(function (Collection $records): void {
foreach ($records as $record) {
Supervisor::where('id', '=', $record->id)
->update(
['is_supervisor' => 1]
);
}
}),
BulkAction::make('Not as supervisor')
->icon('phosphor-stop')
->action(function (Collection $records): void {
foreach ($records as $record) {
Supervisor::where('id', '=', $record->id)
->update(
['is_supervisor' => 0]
);
}
}),
DeleteBulkAction::make(),
]),
@@ -13,6 +13,8 @@ class UsersTable
public static function configure(Table $table): Table
{
return $table
->striped()
->recordAction(null)
->columns([
TextColumn::make('name')
->searchable(),
@@ -36,7 +38,7 @@ class UsersTable
->action(function ($record) {
BettypUserGenerator::run($record);
}),
EditAction::make(),
EditAction::make()->hiddenLabel(),
]);
}
}
+6
View File
@@ -10,6 +10,7 @@ class Supervisor extends Model
'name',
'provider_id',
'sport_id',
'txodds_market_id',
'sleep',
'limit',
'runtime',
@@ -31,4 +32,9 @@ class Supervisor extends Model
{
return $this->belongsTo(Provider::class);
}
public function txodds_market()
{
return $this->belongsTo(TxoddsMarket::class);
}
}