You can now follow picarto streams (.picarto/.pa)
This commit is contained in:
parent
940600bda6
commit
7a85677d74
@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
string Title { get; }
|
||||
bool Live { get; }
|
||||
string Game { get; }
|
||||
int FollowerCount { get; }
|
||||
int Followers { get; }
|
||||
string Url { get; }
|
||||
string Icon { get; }
|
||||
}
|
||||
@ -26,7 +26,6 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
public string Title => "";
|
||||
public bool Live => IsLive == "1";
|
||||
public string Game => "";
|
||||
public int FollowerCount => Followers;
|
||||
public string Icon => !string.IsNullOrWhiteSpace(UserLogo)
|
||||
? "https://edge.sf.hitbox.tv" + UserLogo
|
||||
: "";
|
||||
@ -34,6 +33,25 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
public string Url { get; set; }
|
||||
}
|
||||
|
||||
public class PicartoResponse : IStreamResponse
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Viewers { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("online")]
|
||||
public bool Live { get; set; }
|
||||
[JsonProperty("category")]
|
||||
public string Game { get; set; }
|
||||
|
||||
public int Followers { get; set; }
|
||||
|
||||
public string Url => "https://picarto.tv/" + Name;
|
||||
[JsonProperty("thumbnail")]
|
||||
public string Icon { get; set; }
|
||||
}
|
||||
|
||||
public class TwitchResponse : IStreamResponse
|
||||
{
|
||||
public string Error { get; set; } = null;
|
||||
@ -58,7 +76,7 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
public string Title => Stream?.Channel?.Status;
|
||||
public bool Live => IsLive;
|
||||
public string Game => Stream?.Game;
|
||||
public int FollowerCount => Stream?.Channel?.Followers ?? 0;
|
||||
public int Followers => Stream?.Channel?.Followers ?? 0;
|
||||
public string Url { get; set; }
|
||||
public string Icon => Stream?.Channel?.Logo;
|
||||
}
|
||||
@ -89,7 +107,7 @@ namespace NadekoBot.Modules.Searches.Common
|
||||
public string Title => Name;
|
||||
public bool Live => IsLive;
|
||||
public string Game => Type?.Name ?? "";
|
||||
public int FollowerCount => NumFollowers;
|
||||
public int Followers => NumFollowers;
|
||||
public string Icon => Thumbnail?.Url;
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,17 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
bmData.Url = beamUrl;
|
||||
_cachedStatuses.AddOrUpdate(beamUrl, bmData, (key, old) => bmData);
|
||||
return bmData;
|
||||
case FollowedStream.FollowedStreamType.Picarto:
|
||||
var picartoUrl = $"https://api.picarto.tv/v1/channel/name/{stream.Username.ToLowerInvariant()}";
|
||||
if (checkCache && _cachedStatuses.TryGetValue(picartoUrl, out result))
|
||||
return result;
|
||||
|
||||
var paResponse = await _http.GetAsync(picartoUrl).ConfigureAwait(false);
|
||||
if(!paResponse.IsSuccessStatusCode)
|
||||
throw new StreamNotFoundException($"{stream.Username} [{stream.Type}]");
|
||||
var paData = JsonConvert.DeserializeObject<PicartoResponse>(await paResponse.Content.ReadAsStringAsync());
|
||||
_cachedStatuses.AddOrUpdate(picartoUrl, paData, (key, old) => paData);
|
||||
return paData;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -155,7 +166,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
true);
|
||||
|
||||
embed.AddField(GetText(fs, "followers"),
|
||||
status.FollowerCount.ToString(),
|
||||
status.Followers.ToString(),
|
||||
true);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(status.Icon))
|
||||
@ -178,6 +189,8 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
return $"https://www.twitch.tv/{fs.Username}/";
|
||||
if (fs.Type == FollowedStream.FollowedStreamType.Mixer)
|
||||
return $"https://www.mixer.com/{fs.Username}/";
|
||||
if (fs.Type == FollowedStream.FollowedStreamType.Picarto)
|
||||
return $"https://www.picarto.tv/{fs.Username}";
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,13 @@ namespace NadekoBot.Modules.Searches
|
||||
await TrackStream((ITextChannel)Context.Channel, username, FollowedStream.FollowedStreamType.Twitch)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.ManageMessages)]
|
||||
public async Task Picarto([Remainder] string username) =>
|
||||
await TrackStream((ITextChannel)Context.Channel, username, FollowedStream.FollowedStreamType.Picarto)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[RequireUserPermission(GuildPermission.ManageMessages)]
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
public enum FollowedStreamType
|
||||
{
|
||||
Twitch, Smashcast, Mixer
|
||||
Twitch, Smashcast, Mixer,
|
||||
Picarto
|
||||
}
|
||||
|
||||
public override int GetHashCode() =>
|
||||
|
@ -21,7 +21,7 @@ namespace NadekoBot.Core.Services.Impl
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly DateTime _started;
|
||||
|
||||
public const string BotVersion = "2.5.3";
|
||||
public const string BotVersion = "2.5.4";
|
||||
|
||||
public string Author => "Kwoth#2560";
|
||||
public string Library => "Discord.Net";
|
||||
|
@ -1357,21 +1357,28 @@
|
||||
},
|
||||
"smashcast": {
|
||||
"Cmd": "smashcast hb",
|
||||
"Desc": "Notifies this channel when a certain user starts streaming.",
|
||||
"Desc": "Notifies this channel when the specified user starts streaming.",
|
||||
"Usage": [
|
||||
"{0}smashcast SomeStreamer"
|
||||
]
|
||||
},
|
||||
"twitch": {
|
||||
"Cmd": "twitch tw",
|
||||
"Desc": "Notifies this channel when a certain user starts streaming.",
|
||||
"Desc": "Notifies this channel when the specified user starts streaming.",
|
||||
"Usage": [
|
||||
"{0}twitch SomeStreamer"
|
||||
]
|
||||
},
|
||||
"picarto": {
|
||||
"Cmd": "picarto pa",
|
||||
"Desc": "Notifies this channel when the specified user starts streaming.",
|
||||
"Usage": [
|
||||
"{0}picarto SomeStreamer"
|
||||
]
|
||||
},
|
||||
"mixer": {
|
||||
"Cmd": "mixer bm",
|
||||
"Desc": "Notifies this channel when a certain user starts streaming.",
|
||||
"Desc": "Notifies this channel when the specified user starts streaming.",
|
||||
"Usage": [
|
||||
"{0}mixer SomeStreamer"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user