mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Fix the supermosquito. Hopefully.
This commit is contained in:
parent
e8dfafa17a
commit
797f0be617
11 changed files with 133 additions and 22 deletions
|
@ -9,6 +9,10 @@
|
|||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -10,6 +10,10 @@
|
|||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -9,6 +9,10 @@
|
|||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -9,6 +9,10 @@
|
|||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -7,7 +7,11 @@
|
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -9,39 +9,42 @@ using Newtonsoft.Json;
|
|||
using System.IO;
|
||||
using static ShiftOS.Server.Program;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace ShiftOS.Server
|
||||
{
|
||||
public static class ChatBackend
|
||||
{
|
||||
public static void StartDiscordBots()
|
||||
public static async Task StartDiscordBots()
|
||||
{
|
||||
Reinitialized?.Invoke();
|
||||
if (!File.Exists("chats.json"))
|
||||
File.WriteAllText("chats.json", "[]");
|
||||
foreach (var chat in JsonConvert.DeserializeObject<List<ShiftOS.Objects.Channel>>(File.ReadAllText("chats.json")))
|
||||
{
|
||||
|
||||
bool chatKilled = false;
|
||||
if (chat.IsDiscordProxy == true)
|
||||
{
|
||||
DiscordConfigBuilder builder = new DiscordConfigBuilder();
|
||||
builder.AppName = "ShiftOS";
|
||||
builder.AppVersion = System.Reflection.Assembly.GetExecutingAssembly().FullName;
|
||||
builder.AppUrl = "http://getshiftos.ml/";
|
||||
var client = new DiscordClient(builder);
|
||||
client.Connect(chat.DiscordBotToken, TokenType.Bot);
|
||||
client.SetGame("ShiftOS");
|
||||
client.SetStatus(UserStatus.Online);
|
||||
client.MessageReceived += (s, e) =>
|
||||
DiscordSocketConfig builder = new DiscordSocketConfig();
|
||||
builder.AudioMode = Discord.Audio.AudioMode.Disabled;
|
||||
var client = new DiscordSocketClient(builder);
|
||||
await client.LoginAsync(TokenType.Bot, chat.DiscordBotToken);
|
||||
|
||||
await client.ConnectAsync();
|
||||
await client.SetGameAsync("ShiftOS");
|
||||
await client.SetStatusAsync(UserStatus.Online);
|
||||
client.MessageReceived += async (s) =>
|
||||
{
|
||||
if (chatKilled == false)
|
||||
{
|
||||
if (e.Channel.Id.ToString() == chat.DiscordChannelID)
|
||||
if (s.Channel.Id == Convert.ToUInt64(chat.DiscordChannelID))
|
||||
{
|
||||
server.DispatchAll(new NetObject("chat_msgreceived", new ServerMessage
|
||||
{
|
||||
Name = "chat_msgreceived",
|
||||
GUID = "server",
|
||||
Contents = JsonConvert.SerializeObject(new ChatMessage(e.User.Name, "discord_" + e.Channel.Name, e.Message.Text, chat.ID))
|
||||
Contents = JsonConvert.SerializeObject(new ChatMessage(s.Author.Mention, "discord_" + s.Channel.Name, s.Content, chat.ID))
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +57,9 @@ namespace ShiftOS.Server
|
|||
if (msg.Channel == chat.ID)
|
||||
{
|
||||
//Get the Discord channel for this chat.
|
||||
var dChan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID));
|
||||
var dChan = client.GetChannel(Convert.ToUInt64(chat.ID)) as ISocketMessageChannel;
|
||||
//Relay the message to Discord.
|
||||
dChan.SendMessage($"**[{msg.Username}@{msg.SystemName} ({msg.Channel})]: {msg.Message}");
|
||||
dChan.SendMessageAsync($"**[{msg.Username}@{msg.SystemName}] `<mud/{msg.Channel}> {msg.Message}");
|
||||
|
||||
}
|
||||
//Relay it back to all MUD clients.
|
||||
|
@ -65,8 +68,8 @@ namespace ShiftOS.Server
|
|||
};
|
||||
Reinitialized += () =>
|
||||
{
|
||||
client.Disconnect();
|
||||
client.Dispose();
|
||||
client.DisconnectAsync();
|
||||
|
||||
chatKilled = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,8 +33,24 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Discord.Net, Version=0.9.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.0.9.6\lib\net45\Discord.Net.dll</HintPath>
|
||||
<Reference Include="Discord.Net.Commands, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.Commands.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Commands.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.Core.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Rest, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.Rest.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rest.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.Rpc, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.Rpc.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rpc.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Discord.Net.WebSocket, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Discord.Net.WebSocket.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.WebSocket.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NetSockets">
|
||||
|
@ -61,8 +77,28 @@
|
|||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Interactive.Async.3.1.0\lib\net45\System.Interactive.Async.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Runtime.DurableInstancing" />
|
||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Remoting" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
|
|
@ -1,9 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Discord.Net" version="0.9.6" targetFramework="net451" />
|
||||
<package id="Discord.Net" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="Discord.Net.Commands" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="Discord.Net.Core" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="Discord.Net.Rest" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="Discord.Net.Rpc" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="Discord.Net.WebSocket" version="1.0.0-rc-00595" targetFramework="net451" />
|
||||
<package id="DynamicLua" version="1.1.2.0" targetFramework="net452" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="net451" />
|
||||
<package id="NETStandard.Library" version="1.6.0" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
|
||||
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
|
||||
<package id="RestSharp" version="105.2.3" targetFramework="net451" />
|
||||
<package id="System.Collections" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net451" />
|
||||
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="net451" />
|
||||
<package id="System.Diagnostics.Tracing" version="4.1.0" targetFramework="net451" />
|
||||
<package id="System.Globalization" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Interactive.Async" version="3.1.0" targetFramework="net451" />
|
||||
<package id="System.IO" version="4.1.0" targetFramework="net451" />
|
||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Net.Http" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Net.Primitives" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.ObjectModel" version="4.0.12" targetFramework="net451" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net451" />
|
||||
<package id="System.Reflection.Primitives" version="4.0.1" targetFramework="net451" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Runtime" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net451" />
|
||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net451" />
|
||||
<package id="System.Runtime.Numerics" version="4.0.1" targetFramework="net451" />
|
||||
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net451" />
|
||||
<package id="System.Text.Encoding" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="net451" />
|
||||
<package id="System.Threading" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Threading.Timer" version="4.0.1" targetFramework="net451" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net451" />
|
||||
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="net451" />
|
||||
<package id="WebSocket4Net" version="0.14.1" targetFramework="net451" />
|
||||
</packages>
|
|
@ -8,7 +8,11 @@
|
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
|
Loading…
Reference in a new issue