Skip to content

Commit

Permalink
Bumped Version Number (2.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CriticalFlaw committed Sep 18, 2019
1 parent b07adba commit 419a893
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 55 deletions.
6 changes: 3 additions & 3 deletions src/FlawBOT.Core/FlawBOT.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<StartupObject>FlawBOT.Program</StartupObject>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.2.0</Version>
<Version>2.3.0</Version>
<Win32Resource />
<LangVersion>7.2</LangVersion>
<AssemblyVersion>2.2.0</AssemblyVersion>
<FileVersion>2.2.0</FileVersion>
<AssemblyVersion>2.3.0</AssemblyVersion>
<FileVersion>2.3.0</FileVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyName>FlawBOT.Core</AssemblyName>
<RootNamespace>FlawBOT.Core</RootNamespace>
Expand Down
16 changes: 7 additions & 9 deletions src/FlawBOT.Core/Modules/Search/GoodReadModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
Expand All @@ -25,20 +23,20 @@ public async Task Books(CommandContext ctx,
[Description("Book title to find on GoodReads")] [RemainingText] string query)
{
if (!BotServices.CheckUserInput(query)) return;
var results = GoodReadService.GetBookDataAsync(query).Result;
if (results.Books.Count > 0)
var results = GoodReadService.GetBookDataAsync(query).Result.Search;
if (results.Results.Count <= 0)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
foreach (var book in results.Books)
foreach (var book in results.Results)
{
// TODO: Add page count, publication, ISBN, URLs
var output = new DiscordEmbedBuilder()
.WithTitle(book.Work.Title)
.AddField("Author", book.Work.Author.Name ?? "Unknown", true)
.WithTitle(book.Book.Title)
.AddField("Author", book.Book.Author.Name ?? "Unknown", true)
.AddField("Publication Year", book.PublicationYear.Text ?? "Unknown", true)
.AddField("Ratings", $"Average {book.RatingAverage} ({book.RatingCount} total ratings)", true)
.WithImageUrl(book.Work.ImageUrl ?? book.Work.ImageUrlSmall)
.AddField("Ratings", $"Average {book.RatingAverage} ({book.RatingCount.Text} total ratings)", true)
.WithImageUrl(book.Book.ImageUrl ?? book.Book.ImageUrlSmall)
.WithFooter("Type 'next' within 10 seconds for the next book.")
.WithColor(new DiscordColor("#372213"));
var message = await ctx.RespondAsync(embed: output.Build());
Expand Down
11 changes: 5 additions & 6 deletions src/FlawBOT.Core/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
"discord": null,
"google": null,
"steam": null,
"steam64": null,
"imgur": null,
"omdb": null,
"twitch": null,
"nasa": null,
"teamworktf": null,
"news": null,
"goodreads": null,
"backpacktf": null,
"backpacktf_secret": null,
"backpacktf_schema": null,
"steam64": null,
"reddit_appid": null,
"reddit_access": null,
"reddit_refresh": null,
"news": null,
"goodreads_key": null,
"goodreads_secret": null
}
"reddit_refresh": null
}
5 changes: 3 additions & 2 deletions src/FlawBOT.Framework/FlawBOT.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AssemblyVersion>2.2.0.0</AssemblyVersion>
<Version>2.2.0</Version>
<AssemblyVersion>2.3.0.0</AssemblyVersion>
<Version>2.3.0</Version>
<FileVersion>2.3.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 9 additions & 12 deletions src/FlawBOT.Framework/Models/Bot/BotData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public class TokenData
[JsonProperty("steam")]
public string SteamToken { get; private set; }

[JsonProperty("steam64")]
public string SteamID { get; private set; }

[JsonProperty("imgur")]
public string ImgurToken { get; private set; }

Expand All @@ -34,6 +31,12 @@ public class TokenData
[JsonProperty("teamworktf")]
public string TeamworkToken { get; private set; }

[JsonProperty("news")]
public string NewsToken { get; private set; }

[JsonProperty("goodreads")]
public string GoodReadsToken { get; private set; }

[JsonProperty("backpacktf")]
public string BackpackToken { get; private set; }

Expand All @@ -43,6 +46,9 @@ public class TokenData
[JsonProperty("backpacktf_schema")]
public string BackpackSchema { get; private set; }

[JsonProperty("steam64")]
public string SteamID { get; private set; }

[JsonProperty("reddit_appid")]
public string RedditAppToken { get; private set; }

Expand All @@ -51,15 +57,6 @@ public class TokenData

[JsonProperty("reddit_refresh")]
public string RedditRefreshToken { get; private set; }

[JsonProperty("news")]
public string NewsToken { get; private set; }

[JsonProperty("goodreads_key")]
public string GoodReadsKey { get; private set; }

[JsonProperty("goodreads_secret")]
public string GoodReadsSecret { get; private set; }
}

public enum EmbedType
Expand Down
28 changes: 15 additions & 13 deletions src/FlawBOT.Framework/Models/Search/GoodReadsData.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Collections.Generic;

namespace FlawBOT.Framework.Models
{
[XmlRoot(ElementName = "results")]
public class GoodReadsResponse
[XmlRoot(ElementName = "GoodreadsResponse")]
public class GoodreadsResponse
{
[XmlElement(ElementName = "work")]
public List<Book> Books { get; set; }
[XmlElement("search")]
public GoodreadsSearchInfo Search { get; set; }
}

public class GoodreadsSearchInfo
{
[XmlArray("results"), XmlArrayItem("work")]
public List<Work> Results { get; set; }
}

[XmlRoot(ElementName = "work")]
public class Book
public class Work
{
[XmlElement(ElementName = "best_book")]
public Work Work { get; set; }
public Book Book { get; set; }

[XmlElement(ElementName = "original_publication_day")]
public PublicationDay PublicationDay { get; set; }
Expand All @@ -34,7 +39,7 @@ public class Book
}

[XmlRoot(ElementName = "best_book")]
public class Work
public class Book
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
Expand Down Expand Up @@ -82,8 +87,5 @@ public class RatingsCount
{
[XmlText]
public string Text { get; set; }

[XmlAttribute(AttributeName = "type")]
public string Type { get; set; }
}
}
}
12 changes: 4 additions & 8 deletions src/FlawBOT.Framework/Services/Search/GoodReadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
using FlawBOT.Framework.Common;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Properties;
using Goodreads;
using Goodreads.Http;
using Goodreads.Models.Response;
using Newtonsoft.Json;

namespace FlawBOT.Framework.Services.Search
{
public class GoodReadService : HttpHandler
{
public static async Task<GoodReadsResponse> GetBookDataAsync(string query)
public static async Task<GoodreadsResponse> GetBookDataAsync(string query)
{
var _serializer = new XmlSerializer(typeof(GoodReadsResponse));
var results = await _http.GetStreamAsync(Resources.API_GoodReads + "?key=" + TokenHandler.Tokens.GoodReadsKey + "&q=" + WebUtility.UrlEncode(query));
return (GoodReadsResponse)_serializer.Deserialize(results);
var _serializer = new XmlSerializer(typeof(GoodreadsResponse));
var results = await _http.GetStreamAsync(Resources.API_GoodReads + "?key=" + TokenHandler.Tokens.GoodReadsToken + "&q=" + WebUtility.UrlEncode(query)).ConfigureAwait(false);
return (GoodreadsResponse)_serializer.Deserialize(results);
}
}
}
6 changes: 6 additions & 0 deletions src/FlawBOT.Test/FlawBOT.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>

<AssemblyVersion>2.3.0.0</AssemblyVersion>

<FileVersion>2.3.0.0</FileVersion>

<Version>2.3.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Test/Search/GoodReadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ internal class GoodReadTests
[Test]
public void GetBookData()
{
Assert.IsTrue(GoodReadService.GetBookDataAsync("Ender's Game").Result.Books.Count > 0);
Assert.IsFalse(GoodReadService.GetBookDataAsync("Bender's Game").Result.Books.Count > 0);
Assert.IsTrue(GoodReadService.GetBookDataAsync("Ender's Game").Result.Search.Results.Count > 0);
Assert.IsFalse(GoodReadService.GetBookDataAsync("Bender's Game").Result.Search.Results.Count > 0);
}
}
}

0 comments on commit 419a893

Please sign in to comment.