This commit is contained in:
Kwoth 2016-08-24 15:31:09 +02:00
commit 576690dc81
5 changed files with 366 additions and 6 deletions

11
appveyor.yml Normal file
View File

@ -0,0 +1,11 @@
version: 1.0.{build}
before_build:
- cmd: >-
git submodule update --init --recursive
dotnet restore
cd src/NadekoBot/
build_script:
- cmd: >-
dotnet build

View File

@ -1,5 +1,5 @@
{ {
"projects": [ "discord.net/src/Discord.Net", "discord.net/src/Discord.Net.Commands", "src" ], "projects": [ "discord.net/src", "src" ],
"sdk": { "sdk": {
"version": "1.0.0-preview2-003121" "version": "1.0.0-preview2-003121"
} }

View File

@ -0,0 +1,84 @@
using Discord;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Searches
{
[Group]
public partial class Searches
{
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public static async Task Calculate(IMessage msg, [Remainder] string expression)
{
try
{
var expr = new NCalc.Expression(expression, NCalc.EvaluateOptions.IgnoreCase);
expr.EvaluateParameter += Expr_EvaluateParameter;
expr.EvaluateFunction += Expr_EvaluateFunction;
var result = expr.Evaluate();
await msg.Reply(string.Format("Your expression evaluated to: {0}", expr.Error ?? result));
}
catch (Exception e)
{
await msg.Reply($"Your expression failed to evaluate: {e.Message} ");
}
}
private static void Expr_EvaluateFunction(string name, NCalc.FunctionArgs args)
{
switch (name.ToLowerInvariant())
{
}
}
private static void Expr_EvaluateParameter(string name, NCalc.ParameterArgs args)
{
switch (name.ToLowerInvariant()) {
case "pi": args.Result= Math.PI;
break;
case "e": args.Result = Math.E;
break;
}
}
[Command("calcOperations")]
[RequireContext(ContextType.Guild)]
public async Task calcOperations(IMessage msg)
{
StringBuilder builder = new StringBuilder();
var selection = typeof(Math).GetTypeInfo().GetMethods().Except(typeof(object).GetTypeInfo().GetMethods()).Select(x =>
{
var name = x.Name;
if (x.GetParameters().Any())
{
name += " (" + string.Join(", ", x.GetParameters().Select(y => y.IsOptional ? $"[{y.ParameterType.Name + " " + y.Name }]" : y.ParameterType.Name + " " + y.Name)) + ")";
}
return name;
});
foreach (var method in selection) builder.AppendLine(method);
await msg.ReplyLong(builder.ToString());
}
}
class ExpressionContext
{
public double Pi { get; set; } = Math.PI;
}
}

View File

@ -20,8 +20,7 @@
"Microsoft.Extensions.PlatformAbstractions": "1.0.0", "Microsoft.Extensions.PlatformAbstractions": "1.0.0",
"Newtonsoft.Json": "9.0.1", "Newtonsoft.Json": "9.0.1",
"Microsoft.Extensions.DependencyInjection": "1.0.0", "Microsoft.Extensions.DependencyInjection": "1.0.0",
"Discord.Net": "1.0.0-dev", "Discord.Net.Commands": "1.0.0-dev-*",
"Discord.Net.Commands": "1.0.0-dev",
"System.Resources.ResourceWriter": "4.0.0-beta-22816", "System.Resources.ResourceWriter": "4.0.0-beta-22816",
"Google.Apis.YouTube.v3": "1.15.0.582", "Google.Apis.YouTube.v3": "1.15.0.582",
"Google.Apis.Urlshortener.v1": "1.15.0.138", "Google.Apis.Urlshortener.v1": "1.15.0.138",
@ -30,7 +29,8 @@
"VideoLibrary": "1.3.4", "VideoLibrary": "1.3.4",
"Microsoft.EntityFrameworkCore": "1.0.0", "Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0" "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
"CoreCLR-NCalc": "2.1.0"
}, },
"tools": { "tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"

View File

@ -3,6 +3,26 @@
"version": 2, "version": 2,
"targets": { "targets": {
".NETCoreApp,Version=v1.0": { ".NETCoreApp,Version=v1.0": {
"CoreCLR-NCalc/2.1.0": {
"type": "package",
"dependencies": {
"NETStandard.Library": "1.6.0",
"System.Diagnostics.Debug": "4.0.11",
"System.Linq": "4.1.0",
"System.Linq.Expressions": "4.1.0",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.Serialization.Xml": "4.1.1",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading.Thread": "4.0.0"
},
"compile": {
"lib/netstandard1.3/NCalc.dll": {}
},
"runtime": {
"lib/netstandard1.3/NCalc.dll": {}
}
},
"Google.Apis/1.15.0": { "Google.Apis/1.15.0": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
@ -2105,6 +2125,41 @@
"lib/netstandard1.3/System.ObjectModel.dll": {} "lib/netstandard1.3/System.ObjectModel.dll": {}
} }
}, },
"System.Private.DataContractSerialization/4.1.1": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.11",
"System.Collections.Concurrent": "4.0.12",
"System.Diagnostics.Debug": "4.0.11",
"System.Globalization": "4.0.11",
"System.IO": "4.1.0",
"System.Linq": "4.1.0",
"System.Reflection": "4.1.0",
"System.Reflection.Emit.ILGeneration": "4.0.1",
"System.Reflection.Emit.Lightweight": "4.0.1",
"System.Reflection.Extensions": "4.0.1",
"System.Reflection.Primitives": "4.0.1",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Resources.ResourceManager": "4.0.1",
"System.Runtime": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Text.Encoding": "4.0.11",
"System.Text.Encoding.Extensions": "4.0.11",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading": "4.0.11",
"System.Threading.Tasks": "4.0.11",
"System.Xml.ReaderWriter": "4.0.11",
"System.Xml.XmlDocument": "4.0.1",
"System.Xml.XmlSerializer": "4.0.11"
},
"compile": {
"ref/netstandard/_._": {}
},
"runtime": {
"lib/netstandard1.3/System.Private.DataContractSerialization.dll": {}
}
},
"System.Reflection/4.1.0": { "System.Reflection/4.1.0": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
@ -2422,6 +2477,23 @@
"lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll": {} "lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll": {}
} }
}, },
"System.Runtime.Serialization.Xml/4.1.1": {
"type": "package",
"dependencies": {
"System.IO": "4.1.0",
"System.Private.DataContractSerialization": "4.1.1",
"System.Runtime": "4.1.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Text.Encoding": "4.0.11",
"System.Xml.ReaderWriter": "4.0.11"
},
"compile": {
"ref/netstandard1.3/System.Runtime.Serialization.Xml.dll": {}
},
"runtime": {
"lib/netstandard1.3/System.Runtime.Serialization.Xml.dll": {}
}
},
"System.Security.Claims/4.0.1": { "System.Security.Claims/4.0.1": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
@ -3000,6 +3072,34 @@
"lib/netstandard1.3/System.Xml.XmlDocument.dll": {} "lib/netstandard1.3/System.Xml.XmlDocument.dll": {}
} }
}, },
"System.Xml.XmlSerializer/4.0.11": {
"type": "package",
"dependencies": {
"System.Collections": "4.0.11",
"System.Globalization": "4.0.11",
"System.IO": "4.1.0",
"System.Linq": "4.1.0",
"System.Reflection": "4.1.0",
"System.Reflection.Emit": "4.0.1",
"System.Reflection.Emit.ILGeneration": "4.0.1",
"System.Reflection.Extensions": "4.0.1",
"System.Reflection.Primitives": "4.0.1",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Resources.ResourceManager": "4.0.1",
"System.Runtime": "4.1.0",
"System.Runtime.Extensions": "4.1.0",
"System.Text.RegularExpressions": "4.1.0",
"System.Threading": "4.0.11",
"System.Xml.ReaderWriter": "4.0.11",
"System.Xml.XmlDocument": "4.0.1"
},
"compile": {
"ref/netstandard1.3/_._": {}
},
"runtime": {
"lib/netstandard1.3/System.Xml.XmlSerializer.dll": {}
}
},
"System.Xml.XPath/4.0.1": { "System.Xml.XPath/4.0.1": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
@ -3092,6 +3192,17 @@
} }
}, },
"libraries": { "libraries": {
"CoreCLR-NCalc/2.1.0": {
"sha512": "GUPPo99NUeAgLR5oIOLrApJx3Mx5BZEaKkK9OlDd/CmAYaACLHo68FnO+kCamsLH2+rvr6Rw3hAwzap4GVFV8Q==",
"type": "package",
"path": "CoreCLR-NCalc/2.1.0",
"files": [
"CoreCLR-NCalc.2.1.0.nupkg.sha512",
"CoreCLR-NCalc.nuspec",
"lib/net451/NCalc.dll",
"lib/netstandard1.3/NCalc.dll"
]
},
"Google.Apis/1.15.0": { "Google.Apis/1.15.0": {
"sha512": "B//vbZgUsR0jdJztCJ0ORmVcAzhoiisIsxwc1libVjoZzu+kxUKNJKUl5Wlkj7V28kauS56y3hJUj3FMsgaJZQ==", "sha512": "B//vbZgUsR0jdJztCJ0ORmVcAzhoiisIsxwc1libVjoZzu+kxUKNJKUl5Wlkj7V28kauS56y3hJUj3FMsgaJZQ==",
"type": "package", "type": "package",
@ -6539,6 +6650,20 @@
"ref/xamarinwatchos10/_._" "ref/xamarinwatchos10/_._"
] ]
}, },
"System.Private.DataContractSerialization/4.1.1": {
"sha512": "lcqFBUaCZxPiUkA4dlSOoPZGtZsAuuElH2XHgLwGLxd7ZozWetV5yiz0qGAV2AUYOqw97MtZBjbLMN16Xz4vXA==",
"type": "package",
"path": "System.Private.DataContractSerialization/4.1.1",
"files": [
"System.Private.DataContractSerialization.4.1.1.nupkg.sha512",
"System.Private.DataContractSerialization.nuspec",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/netstandard1.3/System.Private.DataContractSerialization.dll",
"ref/netstandard/_._",
"runtimes/aot/lib/netcore50/System.Private.DataContractSerialization.dll"
]
},
"System.Reflection/4.1.0": { "System.Reflection/4.1.0": {
"sha512": "JCKANJ0TI7kzoQzuwB/OoJANy1Lg338B6+JVacPl4TpUwi3cReg3nMLplMq2uqYfHFQpKIlHAUVAJlImZz/4ng==", "sha512": "JCKANJ0TI7kzoQzuwB/OoJANy1Lg338B6+JVacPl4TpUwi3cReg3nMLplMq2uqYfHFQpKIlHAUVAJlImZz/4ng==",
"type": "package", "type": "package",
@ -7479,6 +7604,76 @@
"runtimes/aot/lib/netcore50/System.Runtime.Serialization.Primitives.dll" "runtimes/aot/lib/netcore50/System.Runtime.Serialization.Primitives.dll"
] ]
}, },
"System.Runtime.Serialization.Xml/4.1.1": {
"sha512": "yqfKHkWUAdI0hdDIdD9KDzluKtZ8IIqLF3O7xIZlt6UTs1bOvFRpCvRTvGQva3Ak/ZM9/nq9IHBJ1tC4Ybcrjg==",
"type": "package",
"path": "System.Runtime.Serialization.Xml/4.1.1",
"files": [
"System.Runtime.Serialization.Xml.4.1.1.nupkg.sha512",
"System.Runtime.Serialization.Xml.nuspec",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net45/_._",
"lib/net46/System.Runtime.Serialization.Xml.dll",
"lib/netcore50/System.Runtime.Serialization.Xml.dll",
"lib/netstandard1.3/System.Runtime.Serialization.Xml.dll",
"lib/portable-net45+win8+wp8+wpa81/_._",
"lib/win8/_._",
"lib/wp80/_._",
"lib/wpa81/_._",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net45/_._",
"ref/net46/System.Runtime.Serialization.Xml.dll",
"ref/netcore50/System.Runtime.Serialization.Xml.dll",
"ref/netcore50/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/de/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/es/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/fr/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/it/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/ja/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/ko/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/ru/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/zh-hans/System.Runtime.Serialization.Xml.xml",
"ref/netcore50/zh-hant/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/System.Runtime.Serialization.Xml.dll",
"ref/netstandard1.0/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/de/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/es/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/fr/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/it/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/ja/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/ko/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/ru/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/zh-hans/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.0/zh-hant/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/System.Runtime.Serialization.Xml.dll",
"ref/netstandard1.3/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/de/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/es/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/fr/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/it/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/ja/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/ko/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/ru/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/zh-hans/System.Runtime.Serialization.Xml.xml",
"ref/netstandard1.3/zh-hant/System.Runtime.Serialization.Xml.xml",
"ref/portable-net45+win8+wp8+wpa81/_._",
"ref/win8/_._",
"ref/wp80/_._",
"ref/wpa81/_._",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._"
]
},
"System.Security.Claims/4.0.1": { "System.Security.Claims/4.0.1": {
"sha512": "4Jlp0OgJLS/Voj1kyFP6MJlIYp3crgfH8kNQk2p7+4JYfc1aAmh9PZyAMMbDhuoolGNtux9HqSOazsioRiDvCw==", "sha512": "4Jlp0OgJLS/Voj1kyFP6MJlIYp3crgfH8kNQk2p7+4JYfc1aAmh9PZyAMMbDhuoolGNtux9HqSOazsioRiDvCw==",
"type": "package", "type": "package",
@ -8641,6 +8836,75 @@
"ref/xamarinwatchos10/_._" "ref/xamarinwatchos10/_._"
] ]
}, },
"System.Xml.XmlSerializer/4.0.11": {
"sha512": "FrazwwqfIXTfq23mfv4zH+BjqkSFNaNFBtjzu3I9NRmG8EELYyrv/fJnttCIwRMFRR/YKXF1hmsMmMEnl55HGw==",
"type": "package",
"path": "System.Xml.XmlSerializer/4.0.11",
"files": [
"System.Xml.XmlSerializer.4.0.11.nupkg.sha512",
"System.Xml.XmlSerializer.nuspec",
"ThirdPartyNotices.txt",
"dotnet_library_license.txt",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net45/_._",
"lib/netcore50/System.Xml.XmlSerializer.dll",
"lib/netstandard1.3/System.Xml.XmlSerializer.dll",
"lib/portable-net45+win8+wp8+wpa81/_._",
"lib/win8/_._",
"lib/wp80/_._",
"lib/wpa81/_._",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net45/_._",
"ref/netcore50/System.Xml.XmlSerializer.dll",
"ref/netcore50/System.Xml.XmlSerializer.xml",
"ref/netcore50/de/System.Xml.XmlSerializer.xml",
"ref/netcore50/es/System.Xml.XmlSerializer.xml",
"ref/netcore50/fr/System.Xml.XmlSerializer.xml",
"ref/netcore50/it/System.Xml.XmlSerializer.xml",
"ref/netcore50/ja/System.Xml.XmlSerializer.xml",
"ref/netcore50/ko/System.Xml.XmlSerializer.xml",
"ref/netcore50/ru/System.Xml.XmlSerializer.xml",
"ref/netcore50/zh-hans/System.Xml.XmlSerializer.xml",
"ref/netcore50/zh-hant/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/System.Xml.XmlSerializer.dll",
"ref/netstandard1.0/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/de/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/es/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/fr/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/it/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/ja/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/ko/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/ru/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/zh-hans/System.Xml.XmlSerializer.xml",
"ref/netstandard1.0/zh-hant/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/System.Xml.XmlSerializer.dll",
"ref/netstandard1.3/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/de/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/es/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/fr/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/it/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/ja/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/ko/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/ru/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/zh-hans/System.Xml.XmlSerializer.xml",
"ref/netstandard1.3/zh-hant/System.Xml.XmlSerializer.xml",
"ref/portable-net45+win8+wp8+wpa81/_._",
"ref/win8/_._",
"ref/wp80/_._",
"ref/wpa81/_._",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"runtimes/aot/lib/netcore50/System.Xml.XmlSerializer.dll"
]
},
"System.Xml.XPath/4.0.1": { "System.Xml.XPath/4.0.1": {
"sha512": "UWd1H+1IJ9Wlq5nognZ/XJdyj8qPE4XufBUkAW59ijsCPjZkZe0MUzKKJFBr+ZWBe5Wq1u1d5f2CYgE93uH7DA==", "sha512": "UWd1H+1IJ9Wlq5nognZ/XJdyj8qPE4XufBUkAW59ijsCPjZkZe0MUzKKJFBr+ZWBe5Wq1u1d5f2CYgE93uH7DA==",
"type": "package", "type": "package",
@ -8738,8 +9002,9 @@
}, },
"projectFileDependencyGroups": { "projectFileDependencyGroups": {
"": [ "": [
"Discord.Net >= 1.0.0-dev", "CoreCLR-NCalc >= 2.1.0",
"Discord.Net.Commands >= 1.0.0-dev", "Discord.Net >= 1.0.0-dev-*",
"Discord.Net.Commands >= 1.0.0-dev-*",
"Google.Apis.Urlshortener.v1 >= 1.15.0.138", "Google.Apis.Urlshortener.v1 >= 1.15.0.138",
"Google.Apis.YouTube.v3 >= 1.15.0.582", "Google.Apis.YouTube.v3 >= 1.15.0.582",
"Microsoft.EntityFrameworkCore >= 1.0.0", "Microsoft.EntityFrameworkCore >= 1.0.0",