mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
[CONFIG][BACKEND] Adds PR announcing to the game.
Adds a C# program that allows you to parse GitHub Pull request opening notifications sent to an IRC and display them in-game. Adds authentication to the world/Topic() procs, allowing you to easily and securely input data into the game (EXPORT DOES NOT REQUIRE IT!)
This commit is contained in:
@@ -101,6 +101,9 @@
|
||||
var/rename_cyborg = 0
|
||||
var/ooc_during_round = 0
|
||||
|
||||
var/comms_key = "default_pwd" //Server API key
|
||||
var/comms_allowed = 0 //By default, the server does not allow messages to be sent to it, unless the key is strong enough (this is to prevent misconfigured servers from becoming victims)
|
||||
|
||||
//Used for modifying movement speed for mobs.
|
||||
//Unversal modifiers
|
||||
var/run_speed = 0
|
||||
@@ -265,6 +268,12 @@
|
||||
Tickcomp = 1
|
||||
if("automute_on")
|
||||
automute_on = 1
|
||||
if("comms_key")
|
||||
comms_key = value
|
||||
if(value == "default_pwd" || length(value) <= 6) //It's the default value or less than 6 characters long, warn badmins
|
||||
message_admins("<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>")
|
||||
else
|
||||
comms_allowed = 1
|
||||
else
|
||||
diary << "Unknown setting in configuration: '[name]'"
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ var/next_external_rsc = 0
|
||||
if(holder)
|
||||
add_admin_verbs()
|
||||
admin_memo_show()
|
||||
if(config.comms_key == "default_pwd" || length(config.comms_key) <= 6) //It's the default value or less than 6 characters long, warn badmins
|
||||
src << "<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>"
|
||||
|
||||
log_client_to_db()
|
||||
|
||||
|
||||
@@ -160,6 +160,13 @@
|
||||
s["map_name"] = map_name ? map_name : "Unknown"
|
||||
|
||||
return list2params(s)
|
||||
else if (copytext(T,1,9) == "announce")
|
||||
var/input[] = params2list(T)
|
||||
if(config.comms_allowed)
|
||||
if(input["key"] != config.comms_key)
|
||||
return "Bad Key"
|
||||
else
|
||||
world << "<span class='announce'>New pull request created: [input["announce"]]</span>"
|
||||
|
||||
|
||||
/world/Reboot(var/reason)
|
||||
|
||||
@@ -144,3 +144,6 @@ TICKCOMP 0
|
||||
|
||||
## Comment this out to disable automuting
|
||||
#AUTOMUTE_ON
|
||||
|
||||
## Communication key for receiving data through world/Topic(), you don't want to give this out
|
||||
COMMS_KEY default_pwd
|
||||
@@ -50,6 +50,7 @@ h1.alert, h2.alert {color: #000000;}
|
||||
.userdanger {color: #ff0000; font-weight: bold;}
|
||||
.danger {color: #ff0000;}
|
||||
.warning {color: #ff0000; font-style: italic;}
|
||||
.announce {color: #228b22; font-weight: bold;}
|
||||
.rose {color: #ff5050;}
|
||||
.info {color: #0000CC;}
|
||||
.notice {color: #000099;}
|
||||
|
||||
BIN
tools/PR_announcer_bot/Meebey.SmartIrc4net.dll
Normal file
BIN
tools/PR_announcer_bot/Meebey.SmartIrc4net.dll
Normal file
Binary file not shown.
BIN
tools/PR_announcer_bot/StarkSoftProxy.dll
Normal file
BIN
tools/PR_announcer_bot/StarkSoftProxy.dll
Normal file
Binary file not shown.
7
tools/PR_announcer_bot/config.txt
Normal file
7
tools/PR_announcer_bot/config.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
serverip = 127.0.0.1 //SS13 server IP
|
||||
serverport = 7812
|
||||
commskey = this_is_a_test_key
|
||||
GitHub_bot_name = testbot_github //It'll get the data from this bot
|
||||
IRC_bot_name = testbot_BYOND //This'll be our name
|
||||
IRC_server = irc.rizon.net:6670 //format - server:port
|
||||
IRC_channel = #ircchannel
|
||||
1
tools/PR_announcer_bot/output.txt
Normal file
1
tools/PR_announcer_bot/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
0131022900006397110110111117110991016191451161034511511697116105111110933286105115116978079876532111112101110101100321121171081083211410111311710111511632651001001153211511110910132981111141033210210197116117114101115329710811511132102105120101115321151111091013211511611710210246323551485248583210997115116101114464646106117115116951111101019510911111410195116101115116951001111101169510710510810895109101413210411611611211558474710310511610411798469911110947116103115116971161051111104745116103451151169711610511111047112117108108475148524832381071011216111610410511595105115959795116101115116951071011210
|
||||
BIN
tools/PR_announcer_bot/sendkeys_ss13.exe
Normal file
BIN
tools/PR_announcer_bot/sendkeys_ss13.exe
Normal file
Binary file not shown.
22
tools/PR_announcer_bot/sendkeys_ss13.sln
Normal file
22
tools/PR_announcer_bot/sendkeys_ss13.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sendkeys_ss13", "sendkeys_ss13\sendkeys_ss13.csproj", "{5D939FCB-F326-4B9B-8CEC-B2538126392E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5D939FCB-F326-4B9B-8CEC-B2538126392E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5D939FCB-F326-4B9B-8CEC-B2538126392E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5D939FCB-F326-4B9B-8CEC-B2538126392E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5D939FCB-F326-4B9B-8CEC-B2538126392E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
tools/PR_announcer_bot/sendkeys_ss13.v12.suo
Normal file
BIN
tools/PR_announcer_bot/sendkeys_ss13.v12.suo
Normal file
Binary file not shown.
6
tools/PR_announcer_bot/sendkeys_ss13/App.config
Normal file
6
tools/PR_announcer_bot/sendkeys_ss13/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
tools/PR_announcer_bot/sendkeys_ss13/Meebey.SmartIrc4net.dll
Normal file
BIN
tools/PR_announcer_bot/sendkeys_ss13/Meebey.SmartIrc4net.dll
Normal file
Binary file not shown.
140
tools/PR_announcer_bot/sendkeys_ss13/Program.cs
Normal file
140
tools/PR_announcer_bot/sendkeys_ss13/Program.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Meebey.SmartIrc4net;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
||||
namespace sendkeys_ss13
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
//default values
|
||||
public static string serverIP = "127.0.0.1";
|
||||
public static int serverPort = 11111;
|
||||
public static string commskey = "this_is_a_test_key";
|
||||
public static string IRC_bot_name = "testbot_github";
|
||||
|
||||
public static IrcClient irc = new IrcClient();
|
||||
public static void Main(string[]args)
|
||||
{
|
||||
ReadConf(ref serverIP, ref serverPort);
|
||||
irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
|
||||
irc.SupportNonRfc = true;
|
||||
irc.Connect("irc.rizon.net" , 6670);
|
||||
Console.WriteLine("{DBG} Connected to IRC");
|
||||
irc.Login("vista_fun_bot", "vistas_fun_bot");
|
||||
Console.WriteLine("{DBG} Logged in");
|
||||
irc.RfcJoin("#fukkentestchannel");
|
||||
Console.WriteLine("{DBG} Joining #coderbus");
|
||||
irc.Listen();
|
||||
}
|
||||
|
||||
public static void ReadConf(ref string IP, ref int port)
|
||||
{
|
||||
if (File.Exists("config.txt"))
|
||||
{
|
||||
StreamReader reader = new StreamReader("config.txt");
|
||||
string[] line = reader.ReadLine().Split(' ');
|
||||
if (line[2] != null)
|
||||
{
|
||||
Match match1 = Regex.Match(line[2], @"(\d{1,3}.?){4}"); //rudimentary IP validation
|
||||
if (match1.Success)
|
||||
{
|
||||
serverIP = line[2];
|
||||
Console.WriteLine("Read IP: " + serverIP);
|
||||
}
|
||||
else { Console.WriteLine("IP cannot be validated."); return; }
|
||||
}
|
||||
line = reader.ReadLine().Split(' ');
|
||||
if (line[2] != null)
|
||||
{
|
||||
Match match2 = Regex.Match(line[2], @"\d{1,5}"); //rudimentary port validation
|
||||
if (match2.Success && (Convert.ToInt32(line[2]) < 65535))
|
||||
{
|
||||
serverPort = Convert.ToInt32(line[2]);
|
||||
Console.WriteLine("Read port: " + serverPort);
|
||||
}
|
||||
else { Console.WriteLine("Port cannot be validated."); return; }
|
||||
}
|
||||
line = reader.ReadLine().Split(' ');
|
||||
if (line[2] != null)
|
||||
{
|
||||
commskey = line[2];
|
||||
Console.WriteLine("Commskey read.");
|
||||
}
|
||||
else { Console.WriteLine("No Commskey!"); return; }
|
||||
line = reader.ReadLine().Split(' ');
|
||||
if(line[2] != null)
|
||||
{
|
||||
IRC_bot_name = line[2];
|
||||
Console.WriteLine("Read IRC bot name: " + IRC_bot_name);
|
||||
}
|
||||
else { Console.WriteLine("No botname found."); return; }
|
||||
reader.Close();
|
||||
}
|
||||
else { Console.WriteLine("Config file doesn't exist, using defaults"); return; }
|
||||
}
|
||||
public static void OnChannelMessage(object sender, IrcEventArgs e)
|
||||
{
|
||||
if(e.Data.Nick == IRC_bot_name)
|
||||
{
|
||||
StreamWriter output = new StreamWriter("output.txt");
|
||||
string[] msg = e.Data.Message.Split(' ');
|
||||
for (int i = 0; i < msg.Length; i++)
|
||||
{
|
||||
msg[i] = Regex.Replace(msg[i], @"[\x02\x1F\x0F\x16]|\x03(\d\d?(,\d\d?)?)?", String.Empty); //Sanitizing color codes
|
||||
msg[i] = Regex.Replace(msg[i], @"[\\\&\=\;]", " "); //Filtering out some iffy characters
|
||||
Console.Write(msg[i] + " ");
|
||||
}
|
||||
Console.WriteLine();
|
||||
if (msg[2] == "opened")
|
||||
{
|
||||
byte[] PACKETS = CreatePacket(msg);
|
||||
PACKETS[1] = 0x83;
|
||||
int len = 0;
|
||||
for (int i = 0; i < msg.Length; i++)
|
||||
{
|
||||
len += msg[i].Length + 1;
|
||||
}
|
||||
len += 14 + commskey.Length + 6;
|
||||
PACKETS[3] = (byte) len;
|
||||
|
||||
StringBuilder test = new StringBuilder();
|
||||
for (int i = 0; i < PACKETS.Length; i++)
|
||||
{
|
||||
test.Append(Convert.ToString(PACKETS[i]));
|
||||
}
|
||||
output.WriteLine(Convert.ToString(test));
|
||||
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
IPEndPoint ip = new IPEndPoint(IPAddress.Parse(serverIP), serverPort);
|
||||
|
||||
server.Connect(ip);
|
||||
server.Send(PACKETS);
|
||||
output.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] CreatePacket(string[] msg)
|
||||
{
|
||||
StringBuilder packet = new StringBuilder();
|
||||
packet.Append((char)'\x00');
|
||||
byte x83 = 0x83 ;
|
||||
packet.Append((char)x83);
|
||||
packet.Append((char)'\x00',6);
|
||||
packet.Append("?announce=");
|
||||
for (int i = 0; i < msg.Length; i++)
|
||||
{
|
||||
packet.Append(msg[i] + " ");
|
||||
}
|
||||
packet.Append("&key=");
|
||||
packet.Append(commskey);
|
||||
packet.Append((char)'\x00');
|
||||
return Encoding.ASCII.GetBytes(packet.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("sendkeys_ss13")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("sendkeys_ss13")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("197641d3-a97a-4255-b833-d6481ca4ef54")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
BIN
tools/PR_announcer_bot/sendkeys_ss13/StarkSoftProxy.dll
Normal file
BIN
tools/PR_announcer_bot/sendkeys_ss13/StarkSoftProxy.dll
Normal file
Binary file not shown.
68
tools/PR_announcer_bot/sendkeys_ss13/sendkeys_ss13.csproj
Normal file
68
tools/PR_announcer_bot/sendkeys_ss13/sendkeys_ss13.csproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5D939FCB-F326-4B9B-8CEC-B2538126392E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>sendkeys_ss13</RootNamespace>
|
||||
<AssemblyName>sendkeys_ss13</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Meebey.SmartIrc4net">
|
||||
<HintPath>.\Meebey.SmartIrc4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StarkSoftProxy">
|
||||
<HintPath>.\StarkSoftProxy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="IrcDotNet.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Reference in New Issue
Block a user