Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
Changes available on release tag 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioZumbi12 committed May 22, 2018
1 parent 500b36d commit ba6fb04
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 15 deletions.
31 changes: 31 additions & 0 deletions SEDiscordBridge.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,47 @@ VisualStudioVersion = 15.0.27428.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SEDiscordBridge", "SEDiscordBridge\SEDiscordBridge.csproj", "{D6D9214A-9E67-4A51-A148-A05D45AA5479}"
EndProject
Project("{911E67C6-3D85-4FCE-B560-20A9C3E3FF48}") = "Torch.Server", "..\..\..\SpaceEngineersDedicado\torch-server\Torch.Server.exe", "{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}"
ProjectSection(DebuggerProjectSystem) = preProject
PortSupplier = 00000000-0000-0000-0000-000000000000
Executable = D:\SpaceEngineersDedicado\torch-server\Torch.Server.exe
RemoteMachine = FABIO-PC
StartingDirectory = D:\SpaceEngineersDedicado\torch-server
Environment = Padrão
LaunchingEngine = 00000000-0000-0000-0000-000000000000
UseLegacyDebugEngines = No
LaunchSQLEngine = No
AttachLaunchAction = No
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
No Torch|Any CPU = No Torch|Any CPU
No Torch|x64 = No Torch|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Debug|x64.ActiveCfg = Debug|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Debug|x64.Build.0 = Debug|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.No Torch|Any CPU.ActiveCfg = No Torch|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.No Torch|Any CPU.Build.0 = No Torch|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.No Torch|x64.ActiveCfg = No Torch|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.No Torch|x64.Build.0 = No Torch|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Release|Any CPU.Build.0 = Release|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Release|x64.ActiveCfg = Release|Any CPU
{D6D9214A-9E67-4A51-A148-A05D45AA5479}.Release|x64.Build.0 = Release|Any CPU
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.Debug|Any CPU.ActiveCfg = Release|x64
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.Debug|x64.ActiveCfg = Release|x64
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.No Torch|Any CPU.ActiveCfg = Release|x64
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.No Torch|x64.ActiveCfg = Release|x64
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.Release|Any CPU.ActiveCfg = Release|x64
{46B444E4-2EA1-4E8A-B0D9-413D3EED096A}.Release|x64.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
40 changes: 30 additions & 10 deletions SEDiscordBridge/DiscordBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ private Task Discord_MessageCreated(DSharpPlus.EventArgs.MessageCreateEventArgs
{
string cmd = e.Message.Content.Substring(Plugin.Config.CommandPrefix.Length);
var cmdText = new string(cmd.Skip(1).ToArray());
DiscordMessage dms = null;

if (Plugin.Torch.GameState != TorchGameState.Loaded)
{
dms = discord.SendMessageAsync(e.Channel, "Error: Server is not running.").Result;
SendCmdResponse("Error: Server is not running.", e.Channel);
}
else
{
Expand All @@ -145,7 +144,7 @@ private Task Discord_MessageCreated(DSharpPlus.EventArgs.MessageCreateEventArgs

if (command == null)
{
dms = discord.SendMessageAsync(e.Channel, "R: Command not found: " + cmdText).Result;
SendCmdResponse("R: Command not found: " + cmdText, e.Channel);
}
else
{
Expand All @@ -156,23 +155,40 @@ private Task Discord_MessageCreated(DSharpPlus.EventArgs.MessageCreateEventArgs
var context = new SEDBCommandHandler(Plugin.Torch, command.Plugin, Sync.MyId, argText, splitArgs);
if (command.TryInvoke(context))
{
if (context.Response.ToString().Length > 0)
dms = discord.SendMessageAsync(e.Channel, "R: " + context.Response.ToString()).Result;
var response = context.Response.ToString();
if (response.Length > 0)
{
if (response.Length >= 1996)
{
SendCmdResponse("R: " + response.Substring(0, 1996), e.Channel);
SendCmdResponse(response.Substring(1996), e.Channel);
}
else
{
SendCmdResponse(response, e.Channel);
}
}
Plugin.Log.Info($"Server ran command '{cmd}'");
}
else
{
dms = discord.SendMessageAsync(e.Channel, "R: Error executing command: " + cmdText).Result;
SendCmdResponse("R: Error executing command: " + cmdText, e.Channel);
}
}
}
Task.Delay(10000).ContinueWith(t => dms?.DeleteAsync());
}
});
}
}
return Task.CompletedTask;
}

private void SendCmdResponse(string response, DiscordChannel chann)
{
DiscordMessage dms = discord.SendMessageAsync(chann, response).Result;
if (Plugin.Config.RemoveResponse > 0)
Task.Delay(Plugin.Config.RemoveResponse*1000).ContinueWith(t => dms?.DeleteAsync());
}

private string MentionNameToID(string msg, DiscordChannel chann)
{
var parts = msg.Split(' ');
Expand Down Expand Up @@ -219,8 +235,12 @@ private string MentionIDToName(DiscordMessage ddMsg)
{
if (part.StartsWith("<@") && part.EndsWith(">"))
{
ulong id = ulong.Parse(part.Substring(2, part.Length - 3));
msg = msg.Replace(part, "@"+discord.GetUserAsync(id).Result.Username);
try
{
ulong id = ulong.Parse(part.Substring(2, part.Length - 3));
msg = msg.Replace(part, "@" + discord.GetUserAsync(id).Result.Username);
}
catch (FormatException) { }
}
if (part.StartsWith("<:") && part.EndsWith(">"))
{
Expand Down
3 changes: 3 additions & 0 deletions SEDiscordBridge/SEDBConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ public class SEDBConfig : ViewModel

private string _tokenVisibleState = "Visible";
public string TokenVisibleState { get => _tokenVisibleState; set => SetValue(ref _tokenVisibleState, value); }

private int _removeResponse = 30;
public int RemoveResponse { get => _removeResponse; set => SetValue(ref _removeResponse, value); }
}
}
29 changes: 26 additions & 3 deletions SEDiscordBridge/SEDBControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
<TextBox Width="180" Text="{Binding ServerName}" ToolTip="The server name to show for discord messages, if message as server enabled" Margin="3" />
<Label Content="Server Name"/>
</StackPanel>


<Label Height="20">
<LineBreak/>
</Label>

<Label FontWeight="Bold" FontSize="16" Content="Commands:" />
<StackPanel Orientation="Horizontal">
<TextBox Width="180" Text="{Binding CommandChannelId}" ToolTip="Discord channel to send commands to Torch" Margin="3" />
Expand All @@ -51,7 +55,15 @@
<TextBox Width="180" Text="{Binding CommandPrefix}" ToolTip="Prefix for Commands from Discord" Margin="3" />
<Label Content="Commands Prefix"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<TextBox Width="180" Text="{Binding RemoveResponse}" ToolTip="Time in seconds to remove the command response from discord." Margin="3" />
<Label Content="Remove response interval ('0' to don't remove)"/>
</StackPanel>

<Label Height="20">
<LineBreak/>
</Label>

<Label FontWeight="Bold" FontSize="16" Content="Status Messages:" />
<StackPanel Orientation="Horizontal">
<TextBox Width="180" Text="{Binding StatusChannelId}" ToolTip="Discord channel to send status messages" Margin="3" />
Expand All @@ -77,7 +89,11 @@
<TextBox Width="180" Text="{Binding Leave}" Margin="3" ToolTip="Use {p} for player name. Leave empty to disable"/>
<Label Content="Player Leave Message" />
</StackPanel>


<Label Height="20">
<LineBreak/>
</Label>

<Label FontWeight="Bold" FontSize="16" Content="BOT Status:" />
<CheckBox Content="Enable BOT Status" Margin="3" IsChecked="{Binding UseStatus}" />
<StackPanel Orientation="Horizontal">
Expand All @@ -89,10 +105,17 @@
<Label Content="Bot Status Message"/>
</StackPanel>

<Label Height="20">
<LineBreak/>
</Label>

<Label FontWeight="Bold" FontSize="16" Content="Mentions:" />
<CheckBox Content="Allow in-game players mention Discord users?" Margin="3" IsChecked="{Binding MentOthers}" />
<CheckBox Content="Allow in-game players ping @everyone?" Margin="3" IsChecked="{Binding MentEveryone}" />

<Label Height="20">
<LineBreak/>
</Label>
<StackPanel Orientation="Horizontal">
<Button Width="180" Content="Save Config" Click="SaveConfig_OnClick" Margin="3" />
</StackPanel>
Expand Down
32 changes: 31 additions & 1 deletion SEDiscordBridge/SEDiscordBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,40 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'No Torch|AnyCPU'">
<OutputPath>..\..\..\..\SpaceEngineersDedicado\torch-server\Plugins\SEDiscordBridge\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="DSharpPlus, Version=3.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DSharpPlus.3.2.3\lib\net46\DSharpPlus.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.2\lib\net45\NLog.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sandbox.Common">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\Sandbox.Common.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sandbox.Game">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\Sandbox.Game.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sandbox.Graphics">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\Sandbox.Graphics.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand All @@ -74,30 +89,40 @@
</Reference>
<Reference Include="Torch">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\Torch.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Torch.API">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\Torch.API.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Torch.Server">
<Reference Include="Torch.Server, Version=1.3.0.34, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\Torch.Server.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Audio">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.Audio.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Dedicated">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.Dedicated.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Game">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.Game.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Game.XmlSerializers">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.Game.XmlSerializers.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="VRage.Library">
<HintPath>..\..\..\..\SpaceEngineersDedicado\torch-server\DedicatedServer64\VRage.Library.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
Expand Down Expand Up @@ -145,5 +170,10 @@
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Content Include="manifest.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion SEDiscordBridge/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<Name>SEDiscordBridge</Name>
<Guid>E182D3CC-1229-4D7F-B42B-5442981A082D</Guid>
<Repository>TorchAPI/SEDiscordBridge</Repository>
<Version>v1.0</Version>
<Version>v1.3.2</Version>
</PluginManifest>

0 comments on commit ba6fb04

Please sign in to comment.