Fuck Singletons
This commit is contained in:
parent
2e8d4b6125
commit
3ce207749f
7 changed files with 120 additions and 14 deletions
53
.vscode/launch.json
vendored
Normal file
53
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/Geekbot.net/bin/Debug/netcoreapp1.1/Geekbot.net.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/bin/Debug/<target-framework>/Geekbot.net.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"stopAtEntry": false,
|
||||
"launchBrowser": {
|
||||
"enabled": true,
|
||||
"args": "${auto-detect-url}",
|
||||
"windows": {
|
||||
"command": "cmd.exe",
|
||||
"args": "/C start ${auto-detect-url}"
|
||||
},
|
||||
"osx": {
|
||||
"command": "open"
|
||||
},
|
||||
"linux": {
|
||||
"command": "xdg-open"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceRoot}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "dotnet",
|
||||
"isShellCommand": true,
|
||||
"args": [],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
"args": [ ],
|
||||
"isBuildCommand": true,
|
||||
"showOutput": "silent",
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
13
Geekbot.net.userprefs
Normal file
13
Geekbot.net.userprefs
Normal file
|
@ -0,0 +1,13 @@
|
|||
<Properties StartupConfiguration="{FDCB3D92-E7B5-47BB-A9B5-CFAEFA57CDB4}|Default">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Geekbot.net/Program.cs">
|
||||
<Files>
|
||||
<File FileName="Geekbot.net/Program.cs" Line="87" Column="9" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
<MultiItemStartupConfigurations />
|
||||
</Properties>
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using RestSharp;
|
||||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
30
Geekbot.net/Lib/RedisClient.cs
Normal file
30
Geekbot.net/Lib/RedisClient.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public sealed class RedisSingleton
|
||||
{
|
||||
private RedisSingleton()
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect("localhost:6379");
|
||||
if (redis.IsConnected)
|
||||
{
|
||||
Console.WriteLine("Connection to Redis Enstablished");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Connection to Redis Failed");
|
||||
}
|
||||
}
|
||||
private static readonly Lazy<RedisSingleton> lazy = new Lazy<RedisSingleton>(() => new RedisSingleton());
|
||||
public static RedisSingleton Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazy.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
|
@ -12,18 +13,19 @@ namespace Geekbot.net.Lib
|
|||
public StatsRecorder(SocketMessage message)
|
||||
{
|
||||
this.message = message;
|
||||
var db = new RedisSingleton();
|
||||
}
|
||||
|
||||
public async Task UpdateUserRecordAsync()
|
||||
{
|
||||
Console.WriteLine(message.Author.Username + " earned a point");
|
||||
// Console.WriteLine(message.Author.Username + " earned a point");
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task UpdateGuildRecordAsync()
|
||||
{
|
||||
var channel = (SocketGuildChannel) message.Channel;
|
||||
Console.WriteLine(channel.Guild.Name + " earned a point");
|
||||
// Console.WriteLine(channel.Guild.Name + " earned a point");
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,8 @@ namespace Geekbot.net.Modules
|
|||
{
|
||||
var request = new RestRequest("meow.php", Method.GET);
|
||||
|
||||
var response = catClient.Client.Execute<CatObject>(request);
|
||||
await ReplyAsync(response.Data.file);
|
||||
dynamic response = catClient.Client.Execute<dynamic>(request);
|
||||
await ReplyAsync(response.Data["file"]);
|
||||
}
|
||||
}
|
||||
|
||||
public class CatObject
|
||||
{
|
||||
public string file {get;set;}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue