Adding Initial API support, updating readme
This commit is contained in:
parent
6732506dae
commit
92015d8880
27 changed files with 78 additions and 33 deletions
|
@ -8,7 +8,7 @@ using Geekbot.net.Lib;
|
|||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
[Group("admin")]
|
||||
public class AdminCmd : ModuleBase
|
||||
|
@ -85,7 +85,7 @@ namespace Geekbot.net.Modules
|
|||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
await ReplyAsync(
|
||||
$"Sorry, only the botowner can do this");
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||
using Discord.Commands;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Cat : ModuleBase
|
||||
{
|
|
@ -7,7 +7,7 @@ using Geekbot.net.Lib;
|
|||
using Geekbot.net.Lib.Media;
|
||||
using Serilog;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class CheckEm : ModuleBase
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Choose : ModuleBase
|
||||
{
|
|
@ -3,10 +3,10 @@ using System.Threading.Tasks;
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using StackExchange.Redis;
|
||||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Counters : ModuleBase
|
||||
{
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Dice : ModuleBase
|
||||
{
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||
using Discord.Commands;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Dog : ModuleBase
|
||||
{
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class EightBall : ModuleBase
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using Discord.Commands;
|
||||
using Geekbot.net.Lib.Media;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Fortune : ModuleBase
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Google : ModuleBase
|
||||
{
|
|
@ -6,7 +6,7 @@ using Discord.Commands;
|
|||
using Geekbot.net.Lib;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class GuildInfo : ModuleBase
|
||||
{
|
|
@ -3,7 +3,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Help : ModuleBase
|
||||
{
|
|
@ -6,7 +6,7 @@ using Discord.Commands;
|
|||
using Geekbot.net.Lib;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Info : ModuleBase
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using Discord.Commands;
|
||||
using Geekbot.net.Lib.Media;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Panda : ModuleBase
|
||||
{
|
|
@ -1,8 +1,7 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Ping : ModuleBase
|
||||
{
|
|
@ -5,12 +5,11 @@ using System.Threading.Tasks;
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
[Group("quote")]
|
||||
public class Quote : ModuleBase
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||
using Discord.Commands;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Roll : ModuleBase
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Say : ModuleBase
|
||||
{
|
|
@ -4,7 +4,7 @@ using Discord;
|
|||
using Discord.Commands;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Ship : ModuleBase
|
||||
{
|
|
@ -9,7 +9,7 @@ using Geekbot.net.Lib;
|
|||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class UserInfo : ModuleBase
|
||||
{
|
|
@ -5,7 +5,7 @@ using Google.Apis.Services;
|
|||
using Google.Apis.YouTube.v3;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class Youtube : ModuleBase
|
||||
{
|
|
@ -4,7 +4,7 @@ using Discord;
|
|||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Commands
|
||||
{
|
||||
public class mal : ModuleBase
|
||||
{
|
|
@ -18,6 +18,8 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
|
||||
<PackageReference Include="MyAnimeListSharp" Version="1.3.4" />
|
||||
<PackageReference Include="Nancy" Version="2.0.0-clinteastwood" />
|
||||
<PackageReference Include="Nancy.Hosting.Self" Version="2.0.0-clinteastwood" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<PackageReference Include="Serilog" Version="2.6.0-dev-00894" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1-dev-00757" />
|
||||
|
@ -34,5 +36,6 @@
|
|||
<PackageReference Include="System.Runtime.Serialization.Primitives">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Utf8Json" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -10,7 +10,7 @@ namespace Geekbot.net.Lib
|
|||
var loggerCreation = new LoggerConfiguration()
|
||||
.WriteTo.LiterateConsole()
|
||||
.WriteTo.RollingFile("Logs/geekbot-{Date}.txt", shared: true);
|
||||
if (args.Length != 0 && args.Contains("--verbose"))
|
||||
if (args.Contains("--verbose"))
|
||||
{
|
||||
loggerCreation.MinimumLevel.Verbose();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ using Discord.Commands;
|
|||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.Media;
|
||||
using Geekbot.net.WebApi;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nancy.Hosting.Self;
|
||||
using Serilog;
|
||||
using StackExchange.Redis;
|
||||
|
||||
|
@ -72,7 +74,7 @@ namespace Geekbot.net
|
|||
Environment.Exit(102);
|
||||
}
|
||||
|
||||
if (args.Length != 0 && args.Contains("--migrate"))
|
||||
if (args.Contains("--migrate"))
|
||||
{
|
||||
Console.WriteLine("\nYou are about to migrate the database, this will overwrite an already migrated database?");
|
||||
Console.Write("Are you sure [y:N]: ");
|
||||
|
@ -156,12 +158,17 @@ namespace Geekbot.net
|
|||
client.UserUpdated += handlers.UserUpdated;
|
||||
client.UserLeft += handlers.UserLeft;
|
||||
|
||||
if (firstStart || (args.Length != 0 && args.Contains("--reset")))
|
||||
if (firstStart || args.Contains("--reset"))
|
||||
{
|
||||
logger.Information("[Geekbot] Finishing setup");
|
||||
await FinishSetup();
|
||||
logger.Information("[Geekbot] Setup finished");
|
||||
}
|
||||
if (!args.Contains("--disable-api"))
|
||||
{
|
||||
logger.Information("[API] Starting Webserver");
|
||||
new NancyHost(new Uri("http://localhost:4567")).Start();
|
||||
}
|
||||
|
||||
logger.Information("[Geekbot] Done and ready for use\n");
|
||||
}
|
||||
|
|
28
Geekbot.net/WebApi/Status.cs
Normal file
28
Geekbot.net/WebApi/Status.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using Nancy;
|
||||
|
||||
namespace Geekbot.net.WebApi
|
||||
{
|
||||
public class Status : NancyModule
|
||||
{
|
||||
public Status()
|
||||
{
|
||||
Get("/", args =>
|
||||
{
|
||||
var responseBody = new ApiStatusDto()
|
||||
{
|
||||
GeekbotVersion = "3.4",
|
||||
ApiVersion = "0.1",
|
||||
Status = "Online"
|
||||
};
|
||||
return Response.AsJson(responseBody);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class ApiStatusDto
|
||||
{
|
||||
public string GeekbotVersion { get; set; }
|
||||
public string ApiVersion { get; set; }
|
||||
public string Status { get; set; }
|
||||
}
|
||||
}
|
15
readme.md
15
readme.md
|
@ -4,13 +4,13 @@ A General Purpose Discord Bot written in DotNet Core.
|
|||
|
||||
You can invite Geekbot to your server with [this link](https://discordapp.com/oauth2/authorize?client_id=171249478546882561&scope=bot&permissions=1416834054)
|
||||
|
||||
### Technologies
|
||||
## Technologies
|
||||
|
||||
* DotNet Core 2
|
||||
* Redis
|
||||
* Discord.net
|
||||
|
||||
### Running
|
||||
## Running
|
||||
|
||||
Make sure redis is running
|
||||
|
||||
|
@ -21,6 +21,15 @@ Run these commands
|
|||
|
||||
On your first run geekbot will ask for your bot token, everything else is taken care of.
|
||||
|
||||
### Contributing
|
||||
### Launch Parameters
|
||||
|
||||
| Parameter | Description |
|
||||
| --- | --- |
|
||||
| `--verbose` | Show more log information |
|
||||
| `--disable-api` | Disables the webapi on startup |
|
||||
| `--reset` | Resets certain parts of the bot |
|
||||
| `--migrate` | Migrates the database from V3.1 to the new format from V3.2<br> (make sure to backup before running this) |
|
||||
|
||||
## Contributing
|
||||
|
||||
Everyone is free to open an issue or create a pull request
|
||||
|
|
Loading…
Reference in a new issue