Skip to content

Commit d71ae60

Browse files
authored
Merge pull request #2 from Decicus/master
update fork #2
2 parents 0b42af2 + 34e696b commit d71ae60

3 files changed

Lines changed: 335 additions & 292 deletions

File tree

app/Http/Controllers/MiscController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public function currency(Request $request)
7171
return Helper::text('An error has occurred retrieving exchange rates');
7272
}
7373

74+
if (empty($convert)) {
75+
return Helper::text('An error has occurred retrieving exchange rates');
76+
}
77+
7478
if ($convert['success'] === false) {
7579
if (!empty($convert['error'])) {
7680
return Helper::text('An error occurred retrieving exchange rates: ' . $convert['error']['type']);

app/Http/Controllers/TwitchController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ public function gameOrStatus(Request $request, $route, $channel = null)
848848

849849
$getGame = $this->twitchApi->channels($channel, $this->version);
850850

851+
// Invalid API response
852+
if (empty($getGame)) {
853+
return Helper::text(__('generic.error_loading_data_api'));
854+
}
855+
851856
if (isset($getGame['message'])) {
852857
return Helper::text(sprintf('%s - %s', $getGame['error'], $getGame['message']));
853858
}
@@ -1147,7 +1152,7 @@ public function hosts(Request $request, $hosts = null, $channel = null)
11471152

11481153
$names = array_slice($hostList, 0, $limit);
11491154
$others = count($hostList) - $limit;
1150-
$text = __('twitch.multiple_hosts', [
1155+
$text = trans_choice('twitch.multiple_hosts', $others, [
11511156
'channels' => implode($separator, $names),
11521157
'amount' => $others,
11531158
]);
@@ -1652,6 +1657,11 @@ public function subcount(Request $request, $subcount = null, $channel = null)
16521657

16531658
$data = $this->twitchApi->channelSubscriptions($user->id, $token, 1, 0, 'asc', $this->version);
16541659

1660+
// Invalid API response
1661+
if (empty($data)) {
1662+
return Helper::text(__('generic.error_loading_data_api'));
1663+
}
1664+
16551665
if (!empty($data['status'])) {
16561666
if ($data['status'] === 401) {
16571667
return Helper::text($needToReAuth);
@@ -1854,6 +1864,11 @@ public function subEmotes(Request $request, $channel = null)
18541864
return Helper::text('Error occurred retrieving user information for Twitch user: ' . $channel);
18551865
}
18561866

1867+
// API returned an empty response, most likely disabled/banned user or it doesn't exist.
1868+
if (empty($user)) {
1869+
return Helper::text(__('twitch.user_not_found', ['user' => $channel]));
1870+
}
1871+
18571872
if (!empty($user['message'])) {
18581873
return Helper::text($user['message']);
18591874
}

0 commit comments

Comments
 (0)