Add wikipedia api client, add wikipedia command, show errors in chat when debugging

This commit is contained in:
runebaas 2018-04-28 01:01:48 +02:00
parent f4ced55d15
commit 846c928f5f
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
18 changed files with 334 additions and 9 deletions

View file

@ -0,0 +1,14 @@
using System;
namespace WikipediaApi.Page
{
public class PageApiUrls
{
public Uri Summary { get; set; }
public Uri Metadata { get; set; }
public Uri References { get; set; }
public Uri Media { get; set; }
public Uri EditHtml { get; set; }
public Uri TalkPageHtml { get; set; }
}
}

View file

@ -0,0 +1,8 @@
namespace WikipediaApi.Page
{
public class PageContentUrlCollection
{
public PageContentUrls Desktop { get; set; }
public PageContentUrls Mobile { get; set; }
}
}

View file

@ -0,0 +1,12 @@
using System;
namespace WikipediaApi.Page
{
public class PageContentUrls
{
public Uri Page { get; set; }
public Uri Revisions { get; set; }
public Uri Edit { get; set; }
public Uri Talk { get; set; }
}
}

View file

@ -0,0 +1,8 @@
namespace WikipediaApi.Page
{
public class PageCoordinates
{
public float lat { get; set; }
public float lon { get; set; }
}
}

View file

@ -0,0 +1,12 @@
using System;
namespace WikipediaApi.Page
{
public class PageImage
{
public Uri Source { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
}

View file

@ -0,0 +1,8 @@
namespace WikipediaApi.Page
{
public class PageNamespace
{
public ulong Id { get; set; }
public string Text { get; set; }
}
}

View file

@ -0,0 +1,68 @@
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace WikipediaApi.Page
{
public class PagePreview
{
[JsonProperty("type")]
[JsonConverter(typeof(StringEnumConverter))]
public PageTypes Type { get; set; } = PageTypes.NoExtract;
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("displaytitle")]
public string Displaytitle { get; set; }
[JsonProperty("namespace")]
public PageNamespace @Namespace { get; set; }
[JsonProperty("titles")]
public PageTitles Titles { get; set; }
[JsonProperty("pageid")]
public ulong Pageid { get; set; }
[JsonProperty("thumbnail")]
public PageImage Thumbnail { get; set; }
[JsonProperty("originalimage")]
public PageImage Originalimage { get; set; }
[JsonProperty("lang")]
public string Lang { get; set; }
[JsonProperty("dir")]
public string Dir { get; set; }
[JsonProperty("revision")]
public ulong Revision { get; set; }
[JsonProperty("tid")]
public string Tid { get; set; }
[JsonProperty("timestamp")]
public DateTimeOffset Timestamp { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("coordinates")]
public PageCoordinates Coordinates { get; set; }
[JsonProperty("content_urls")]
public PageContentUrlCollection ContentUrls { get; set; }
[JsonProperty("api_urls")]
public PageApiUrls ApiUrls { get; set; }
[JsonProperty("extract")]
public string Extract { get; set; }
[JsonProperty("extract_html")]
public string ExtractHtml { get; set; }
}
}

View file

@ -0,0 +1,10 @@
namespace WikipediaApi.Page
{
public class PageTitles
{
public string Canonical { get; set; }
public string Normalized { get; set; }
public string Display { get; set; }
}
}

View file

@ -0,0 +1,19 @@
using System.Runtime.Serialization;
namespace WikipediaApi.Page
{
public enum PageTypes
{
[EnumMember(Value = "standard")]
Standard,
[EnumMember(Value = "disambiguation")]
Disambiguation,
[EnumMember(Value = "mainpage")]
MainPage,
[EnumMember(Value = "no-extract")]
NoExtract
}
}