summaryrefslogtreecommitdiff
path: root/DiscoBot
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot')
-rw-r--r--DiscoBot/Commands/FileHandler.cs43
-rw-r--r--DiscoBot/Commands/Voice.cs10
-rw-r--r--DiscoBot/DiscoBot.csproj3
3 files changed, 50 insertions, 6 deletions
diff --git a/DiscoBot/Commands/FileHandler.cs b/DiscoBot/Commands/FileHandler.cs
new file mode 100644
index 0000000..efebe3f
--- /dev/null
+++ b/DiscoBot/Commands/FileHandler.cs
@@ -0,0 +1,43 @@
+namespace DiscoBot.Commands
+{
+ using System;
+ using System.Linq;
+ using System.Net;
+
+ using DiscoBot.Auxiliary;
+ using DiscoBot.Characters;
+
+ using Discord.Commands;
+
+ public class FileHandler : ModuleBase
+ {
+ [Command("add"), Summary("fügt Helden hinzu")]
+ public void AddChar()
+ {
+ var msg = this.Context.Message;
+ if (msg.Attachments == null)
+ {
+ throw new ArgumentException("Es wurde keine Datei angehängt");
+ }
+
+ var attachments = msg.Attachments.ToList();
+
+ if (!attachments.Any(x => x.Filename.EndsWith(".xml")))
+ {
+ throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
+ }
+
+ foreach (var attachment in attachments.Where(x => x.Filename.EndsWith(".xml")))
+ {
+ using (var client = new WebClient())
+ {
+ client.DownloadFile(attachment.Url, "helden\\" + attachment.Filename);
+ }
+
+ Dsa.Chars.Add(new Character("helden\\" + attachment.Filename));
+ (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
+ .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v));
+ }
+ }
+ }
+}
diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs
index 72988d4..02210e8 100644
--- a/DiscoBot/Commands/Voice.cs
+++ b/DiscoBot/Commands/Voice.cs
@@ -39,10 +39,10 @@
[Command("play")]
public Task PlayAudioAsync(string path)
{
- return this.SendAsync(Client, path);
+ return SendAsync(path);
}
- private Process CreateStream(string path)
+ private static Process CreateStream(string path)
{
var ffmpeg = new ProcessStartInfo
{
@@ -54,12 +54,12 @@
return Process.Start(ffmpeg);
}
- private async Task SendAsync(IAudioClient client, string path)
+ private static async Task SendAsync(string path)
{
// Create FFmpeg using the previous example
- var ffmpeg = this.CreateStream(path);
+ var ffmpeg = CreateStream(path);
var output = ffmpeg.StandardOutput.BaseStream;
- var discord = client.CreatePCMStream(AudioApplication.Music);
+ var discord = Client.CreatePCMStream(AudioApplication.Music);
await output.CopyToAsync(discord);
await discord.FlushAsync();
}
diff --git a/DiscoBot/DiscoBot.csproj b/DiscoBot/DiscoBot.csproj
index 2bf17e5..3955ef6 100644
--- a/DiscoBot/DiscoBot.csproj
+++ b/DiscoBot/DiscoBot.csproj
@@ -148,16 +148,17 @@
<Compile Include="Characters\Character.cs" />
<Compile Include="Auxiliary\CommandExtension.cs" />
<Compile Include="Commands\CommandTypes.cs" />
+ <Compile Include="Commands\FileHandler.cs" />
<Compile Include="Commands\Gm.cs" />
<Compile Include="Commands\List.cs" />
<Compile Include="Commands\NpcCommands.cs" />
<Compile Include="Commands\Test.cs" />
<Compile Include="Commands\Utility.cs" />
<Compile Include="Commands\Voice.cs" />
- <Compile Include="DSA.cs" />
<Compile Include="Characters\ICharacter.cs" />
<Compile Include="Auxiliary\Misc.cs" />
<Compile Include="Characters\NPC.cs" />
+ <Compile Include="Dsa.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">