summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DSACore/Models/Command.cs2
-rw-r--r--DiscoBot/Commands/FileHandler.cs2
-rw-r--r--DiscoBot/Commands/Gm.cs4
-rw-r--r--DiscoBot/Commands/HeldList.cs2
-rw-r--r--DiscoBot/Commands/Help.cs5
-rw-r--r--DiscoBot/Commands/LebenUndAstral.cs4
-rw-r--r--DiscoBot/Commands/List.cs2
-rw-r--r--DiscoBot/Commands/NpcCommands.cs4
-rw-r--r--DiscoBot/Commands/ProbenTest.cs12
-rw-r--r--DiscoBot/Program.cs44
10 files changed, 61 insertions, 20 deletions
diff --git a/DSACore/Models/Command.cs b/DSACore/Models/Command.cs
index 58be41a..a1bd0b2 100644
--- a/DSACore/Models/Command.cs
+++ b/DSACore/Models/Command.cs
@@ -12,7 +12,7 @@ namespace DSACore.Models
public string Name { get; set; }
public string CmdIdentifier { get; set; }
public List<string> CmdTexts { get; set; }
- public string CmdText => CmdTexts != null ? CmdTexts.First() : "";
+ public string CmdText => CmdTexts.Count != 0 ? CmdTexts.First() : "";
public int Cmdmodifier { get; set; } = 0;
public bool IsDm { get; set; } = false;
diff --git a/DiscoBot/Commands/FileHandler.cs b/DiscoBot/Commands/FileHandler.cs
index 943a6e4..0b87b15 100644
--- a/DiscoBot/Commands/FileHandler.cs
+++ b/DiscoBot/Commands/FileHandler.cs
@@ -13,7 +13,7 @@
public class FileHandler : ModuleBase
{
- [Command("send"), Summary("fügt Helden hinzu")]
+ //[Command("send"), Summary("fügt Helden hinzu")]
public async Task AddChar()
{
var msg = this.Context.Message;
diff --git a/DiscoBot/Commands/Gm.cs b/DiscoBot/Commands/Gm.cs
index 6447f43..483e9d2 100644
--- a/DiscoBot/Commands/Gm.cs
+++ b/DiscoBot/Commands/Gm.cs
@@ -14,7 +14,7 @@ namespace DiscoBot.Commands
public class Iam : ModuleBase
{
- [Command("Iam"), Summary("Wechselt den Character")]
+ //[Command("Iam"), Summary("Wechselt den Character")]
[Alias("iam", "I_am", "i_am", "IchBin", "ichbin", "Ichbin", "Ich_bin", "ich_bin", "Ich", "ich", "I", "i")]
public Task Change_Character(params string[] givenName) // use fancy parameters
{
@@ -80,7 +80,7 @@ namespace DiscoBot.Commands
return $"{name} verwendet {waffe}";
}
- [Command("gm"), Summary("Führt eine probe aus")]
+ //[Command("gm"), Summary("Führt eine probe aus")]
[Alias("GM", "as", "As", "als")]
public async Task ProbeAsync([Summary("Fernkampfwaffe")] string name, string command, string cmdText = "", int modifier = 0)
{
diff --git a/DiscoBot/Commands/HeldList.cs b/DiscoBot/Commands/HeldList.cs
index ab4e794..a8f26e0 100644
--- a/DiscoBot/Commands/HeldList.cs
+++ b/DiscoBot/Commands/HeldList.cs
@@ -15,7 +15,7 @@
public class Held : ModuleBase
{
- [Command("held"), Summary("gibt Heldenwerte aus")]
+ //[Command("held"), Summary("gibt Heldenwerte aus")]
[Alias("Held", "Wert", "Werte", "werte", "char", "Char")]
public async Task ListAsync([Summary("Werte")] params string[] prop_list)
{
diff --git a/DiscoBot/Commands/Help.cs b/DiscoBot/Commands/Help.cs
index aa168fc..4c378c9 100644
--- a/DiscoBot/Commands/Help.cs
+++ b/DiscoBot/Commands/Help.cs
@@ -67,8 +67,9 @@ namespace DiscoBot.Commands
}
return res;
}
+/*
- [Command("help"), Summary("prints the help menu.")]
+ //[Command("help"), Summary("prints the help menu.")]
[Alias("Help", "man", "Man", "Hilfe", "hilfe", "h")]
public async Task ShowHelpAsync(params string[] command_list)
{
@@ -93,6 +94,6 @@ namespace DiscoBot.Commands
//await this.ReplyAsync("```xl\n" + com.GetDescription() + "\n```");
await this.ReplyAsync("```xl\n" + Get_Specific_Help(command) + "\n```");
- }
+ }*/
}
}
diff --git a/DiscoBot/Commands/LebenUndAstral.cs b/DiscoBot/Commands/LebenUndAstral.cs
index 456d2f2..2406c70 100644
--- a/DiscoBot/Commands/LebenUndAstral.cs
+++ b/DiscoBot/Commands/LebenUndAstral.cs
@@ -13,7 +13,7 @@
public class LE : ModuleBase
{
- [Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
+ //[Command("LE"), Summary("Ändert aktuellen Lebenspunktestand")]
[Alias("le", "leben", "LP", "lp", "Le", "Lp")]
public async Task LEAsync([Summary("LE Modifier")] string prop = "", string s = "")
@@ -41,7 +41,7 @@
public class AE : ModuleBase
{
- [Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
+ //[Command("AE"), Summary("Ändert aktuellen Astralpunktestand")]
[Alias("ae", "astral", "ASP", "Asp", "asp", "Astral")]
public async Task AEAsync([Summary("AE Modifier")] string prop = "", string s = "")
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
index a251183..e77362e 100644
--- a/DiscoBot/Commands/List.cs
+++ b/DiscoBot/Commands/List.cs
@@ -15,7 +15,7 @@
public class List : ModuleBase
{
- [Command("list"), Summary("gibt eine Auflistung aus")]
+ //[Command("list"), Summary("gibt eine Auflistung aus")]
public async Task ListAsync([Summary("Aktion")] string prop)
{
var res = new List<string>();
diff --git a/DiscoBot/Commands/NpcCommands.cs b/DiscoBot/Commands/NpcCommands.cs
index 98f4589..b314494 100644
--- a/DiscoBot/Commands/NpcCommands.cs
+++ b/DiscoBot/Commands/NpcCommands.cs
@@ -13,7 +13,7 @@
public class NpcCommands : ModuleBase
{
- [Command("npc"), Summary("Erstellt ein NPC")]
+ //[Command("npc"), Summary("Erstellt ein NPC")]
[Alias("Npc", "NPc", "NPC", "nPC")]
public Task RandomAsync([Summary("Create Random")] string npcName, int mean = 9, int stDv = 1)
{
@@ -21,7 +21,7 @@
return this.ReplyAsync($"{npcName} wurde zufällig generiert");
}
- [Command("npc"), Summary("Erstellt ein NPC")]
+ //[Command("npc"), Summary("Erstellt ein NPC")]
[Alias("Npc", "NPc", "NPC", "nPC")]
public Task CopyAsync([Summary("Create Copy")] string npcName, string source, int stDv = 1)
{
diff --git a/DiscoBot/Commands/ProbenTest.cs b/DiscoBot/Commands/ProbenTest.cs
index 9614b7c..77a10ad 100644
--- a/DiscoBot/Commands/ProbenTest.cs
+++ b/DiscoBot/Commands/ProbenTest.cs
@@ -8,7 +8,7 @@
public class ProbenTest : ModuleBase
{
- [Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
+ //[Command("t"), Summary("Würfelt ein Talent-/Zauberprobe")]
[Alias("T", "Talent", "talent", "versuche")]
public Task TalentAsync([Summary("Talent oder Zaubername")] string talent, int erschwernis = 0)
{
@@ -33,7 +33,7 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
+ //[Command("Zauber"), Summary("Würfelt ein Zauberprobe")]
[Alias("Z", "zauber", "z")]
public Task ZauberAsync([Summary("Zaubername")] string zauber, int erschwernis = 0)
{
@@ -58,7 +58,7 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
+ //[Command("e"), Summary("Würfelt eine Eigenschaftsprobe")]
[Alias("E", "Eigenschaft", "eigenschaft", "eigen")]
public Task EigenschaftAsync([Summary("Eigenschaftskürzel und Erschwernis")] string talent, int erschwernis = 0)
{
@@ -67,21 +67,21 @@
return this.ReplyAsync("```xl\n" + res + "\n```");
}
- [Command("a"), Summary("Würfelt ein Angriff")]
+ //[Command("a"), Summary("Würfelt ein Angriff")]
[Alias("A", "At", "at", "Angriff", "angriff", "attackiere_mit", "attacke", "Attacke")]
public Task AngriffAsync([Summary("Weapon")] string weapon, int erschwernis = 0)
{
return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Angriff(weapon, erschwernis) + "\n```");
}
- [Command("p"), Summary("Würfelt eine Parade Probe")]
+ //[Command("p"), Summary("Würfelt eine Parade Probe")]
[Alias("P", "Parade", "parade", "pariere_mit")]
public Task ParadeAsync([Summary("Parade Weapon")] string talent, int erschwernis = 0)
{
return this.ReplyAsync("```xl\n" + Dsa.Chars.Find(x => x.Name.Equals(Dsa.Session.Relation[this.Context.User.Username])).Parade(talent, erschwernis) + "\n```");
}
- [Command("f"), Summary("Führt eine Fernkampfprobe aus")]
+ //[Command("f"), Summary("Führt eine Fernkampfprobe aus")]
[Alias("F", "fern", "Fern", "Schuss", "schuss", "fernkampf", "Fernkampf", "schieße", "schieße_mit")]
public Task FernkampfAsync([Summary("Fernkampfwaffe")] string waffe, int erschwernis = 0)
{
diff --git a/DiscoBot/Program.cs b/DiscoBot/Program.cs
index 9d3c140..5dc69c1 100644
--- a/DiscoBot/Program.cs
+++ b/DiscoBot/Program.cs
@@ -1,4 +1,6 @@
using System;
+using System.Linq;
+using System.Net;
using System.Reflection;
using System.Threading.Tasks;
@@ -68,7 +70,7 @@ namespace DiscoBot
// Determine if the message is a command, based on if it starts with '!' or a mention prefix
if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(this.client.CurrentUser, ref argPos)))
{
- return;
+ return;
}
@@ -78,12 +80,50 @@ namespace DiscoBot
// Execute the command. (result does not indicate a return value,
// rather an object stating if the command executed successfully)
var result = await this.commands.ExecuteAsync(context, argPos, this.services);
- if (!result.IsSuccess)
+ if (result.Error == CommandError.UnknownCommand)
+ {
+ await context.Channel.SendMessageAsync(SendCommand(message.Author.Username, message.Content, "https://localhost:44365/api/Commands"));
+ }
+ else if (!result.IsSuccess)
{
await context.Channel.SendMessageAsync(result.ErrorReason);
}
}
+ private string SendCommand(string name, string command, string url)
+ {
+ var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
+ httpWebRequest.ContentType = "application/json";
+ httpWebRequest.Method = "POST";
+
+ using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
+ {
+ command = command.Remove(0,1);
+ var args = command.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
+
+ string content = string.Empty;
+ if (args.Length > 1)
+ {
+ content = "\"" + args.Skip(1).Aggregate((s, n) => ( s + "\", \"" + n)) + "\"";
+ }
+
+ string json = "{\"Name\":\"" + name + "\"," +
+ "\"CmdIdentifier\":\"" + args.First() + "\"," +
+ "\"CmdTexts\": ["+ content+"] }";
+
+
+ streamWriter.Write(json);
+ streamWriter.Flush();
+ streamWriter.Close();
+ }
+
+ var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
+ using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
+ {
+ return streamReader.ReadToEnd();
+ }
+ }
+
private static void OnProcessExit(object sender, EventArgs e)
{
Console.WriteLine("I'm out of here");