Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
fkndean
2016-11-30 01:01:48 -05:00
10 changed files with 108 additions and 33 deletions

View File

@@ -156,8 +156,8 @@ You can support the project on patreon: <https://patreon.com/nadekobot> or paypa
var channel = (ITextChannel)umsg.Channel;
await channel.SendMessageAsync(
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/1.0/Commands%20List/>
**Hosting Guides and docs can be found here**: <http://nadekobot.readthedocs.io/en/1.0/>").ConfigureAwait(false);
@"**LIST OF COMMANDS**: <http://nadekobot.readthedocs.io/en/latest/Commands%20List/>
**Hosting Guides and docs can be found here**: <http://nadekobot.readthedocs.io/en/latest/>").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]

View File

@@ -1,4 +1,5 @@
using Discord;
using Discord.API;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
@@ -37,9 +38,36 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(query))
return;
var result = await GetAnimeData(query).ConfigureAwait(false);
var animeData = await GetAnimeData(query).ConfigureAwait(false);
await channel.SendMessageAsync(result.ToString() ?? "`No anime found.`").ConfigureAwait(false);
var embed = new Discord.API.Embed()
{
Description = animeData.Synopsis,
Title = animeData.title_english,
Url = animeData.Link,
Image = new Discord.API.EmbedImage() {
Url = animeData.image_url_lge
},
Fields = new[] {
new Discord.API.EmbedField() {
Inline = true,
Name = "Episodes",
Value = animeData.total_episodes.ToString()
},
new Discord.API.EmbedField() {
Inline = true,
Name = "Status",
Value = animeData.AiringStatus.ToString()
},
new Discord.API.EmbedField() {
Inline = true,
Name = "Genres",
Value = String.Join(", ", animeData.Genres)
}
},
Color = NadekoBot.OkColor
};
await channel.EmbedAsync(embed).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
@@ -51,9 +79,38 @@ namespace NadekoBot.Modules.Searches
if (string.IsNullOrWhiteSpace(query))
return;
var result = await GetMangaData(query).ConfigureAwait(false);
var animeData = await GetMangaData(query).ConfigureAwait(false);
await channel.SendMessageAsync(result.ToString() ?? "`No manga found.`").ConfigureAwait(false);
var embed = new Discord.API.Embed()
{
Description = animeData.Synopsis,
Title = animeData.title_english,
Url = animeData.Link,
Image = new Discord.API.EmbedImage()
{
Url = animeData.image_url_lge
},
Fields = new[] {
new Discord.API.EmbedField() {
Inline = true,
Name = "Chapters",
Value = animeData.total_chapters.ToString()
},
new Discord.API.EmbedField() {
Inline = true,
Name = "Status",
Value = animeData.publishing_status.ToString()
},
new Discord.API.EmbedField() {
Inline = true,
Name = "Genres",
Value = String.Join(", ", animeData.Genres)
}
},
Color = NadekoBot.OkColor
};
await channel.EmbedAsync(embed).ConfigureAwait(false);
}
private async Task<AnimeResult> GetAnimeData(string query)

View File

@@ -1,20 +1,19 @@
namespace NadekoBot.Modules.Searches.Models
using NadekoBot.Extensions;
using System.Globalization;
namespace NadekoBot.Modules.Searches.Models
{
public class AnimeResult
{
public int id;
public string AiringStatus => airing_status.ToTitleCase();
public string airing_status;
public string title_english;
public int total_episodes;
public string description;
public string image_url_lge;
public override string ToString() =>
"`Title:` **" + title_english +
"**\n`Status:` " + airing_status +
"\n`Episodes:` " + total_episodes +
"\n`Link:` http://anilist.co/anime/" + id +
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
"\n`img:` " + image_url_lge;
public string[] Genres;
public string Link => "http://anilist.co/anime/" + id;
public string Synopsis => description?.Substring(0, description.Length > 500 ? 500 : description.Length) + "...";
}
}

View File

@@ -9,14 +9,8 @@ namespace NadekoBot.Modules.Searches.Models
public int total_chapters;
public int total_volumes;
public string description;
public override string ToString() =>
"`Title:` **" + title_english +
"**\n`Status:` " + publishing_status +
"\n`Chapters:` " + total_chapters +
"\n`Volumes:` " + total_volumes +
"\n`Link:` http://anilist.co/manga/" + id +
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
"\n`img:` " + image_url_lge;
public string[] Genres;
public string Link => "http://anilist.co/manga/" + id;
public string Synopsis => description?.Substring(0, description.Length > 500 ? 500 : description.Length) + "...";
}
}

View File

@@ -43,12 +43,18 @@ namespace NadekoBot.Modules.Searches
var obj = JObject.Parse(response)["weather"];
await channel.SendMessageAsync(
$@"🌍 **Weather for** 【{obj["target"]}】
📏 **Lat,Long:** ({obj["latitude"]}, {obj["longitude"]}) **Condition:** {obj["condition"]}
😓 **Humidity:** {obj["humidity"]}% 💨 **Wind Speed:** {obj["windspeedk"]}km/h / {obj["windspeedm"]}mph
🌡 **Temperature:** {obj["centigrade"]}°C / {obj["fahrenheit"]}°F 🔆 **Feels like:** {obj["feelscentigrade"]}°C / {obj["feelsfahrenheit"]}°F
🌄 **Sunrise:** {obj["sunrise"]} 🌇 **Sunset:** {obj["sunset"]}").ConfigureAwait(false);
var embed = new EmbedBuilder()
.AddField(fb => fb.WithName("🌍 Location").WithValue($"{obj["target"]}").WithIsInline(true))
.AddField(fb => fb.WithName("📏 Lat,Long").WithValue($"{obj["latitude"]}, {obj["longitude"]}").WithIsInline(true))
.AddField(fb => fb.WithName("☁ Condition").WithValue($"{obj["condition"]}").WithIsInline(true))
.AddField(fb => fb.WithName("😓 Humidity").WithValue($"{obj["humidity"]}%").WithIsInline(true))
.AddField(fb => fb.WithName("💨 Wind Speed").WithValue($"{obj["windspeedk"]}km/h / {obj["windspeedm"]}mph").WithIsInline(true))
.AddField(fb => fb.WithName("🌡 Temperature").WithValue($"{obj["centigrade"]}°C / {obj["fahrenheit"]}°F").WithIsInline(true))
.AddField(fb => fb.WithName("🔆 Feels like").WithValue($"{obj["feelscentigrade"]}°C / {obj["feelsfahrenheit"]}°F").WithIsInline(true))
.AddField(fb => fb.WithName("🌄 Sunrise").WithValue($"{obj["sunrise"]}").WithIsInline(true))
.AddField(fb => fb.WithName("🌇 Sunset").WithValue($"{obj["sunset"]}").WithIsInline(true))
.WithColor(NadekoBot.OkColor);
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]