Skip to content

Instantly share code, notes, and snippets.

@Cyberboss
Created August 24, 2017 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cyberboss/a64f2b2207448edd260620ec8ace7f53 to your computer and use it in GitHub Desktop.
Save Cyberboss/a64f2b2207448edd260620ec8ace7f53 to your computer and use it in GitHub Desktop.
How I got 30k
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="OpenPRWhenIssueNIsReached.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<OpenPRWhenIssueNIsReached.Properties.Settings>
<setting name="MyJobIsDone" serializeAs="String">
<value>False</value>
</setting>
</OpenPRWhenIssueNIsReached.Properties.Settings>
</userSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>OpenPRWhenIssueNIsReached</RootNamespace>
<AssemblyName>OpenPRWhenIssueNIsReached</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</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>packages\SmartIrc4net.1.1\lib\Meebey.SmartIrc4net.dll</HintPath>
</Reference>
<Reference Include="Octokit">
<HintPath>packages\Octokit.0.24.0\lib\net45\Octokit.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPRWhenIssueNIsReached", "OpenPRWhenIssueNIsReached.csproj", "{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23D9FD87-F588-434B-A4EB-7EC5CDDE0066}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Octokit" version="0.24.0" targetFramework="net452" />
<package id="SmartIrc4net" version="1.1" targetFramework="net452" />
</packages>
using Meebey.SmartIrc4net;
using Octokit;
using System;
using System.ServiceProcess;
using System.Threading;
namespace OpenPRWhenIssueNIsReached
{
class Program : ServiceBase
{
uint target_pr = 30000;
ushort ServerPort = 6667;
IrcFeatures client;
string PRName = "Credits Roll", PRDesc = ":cl:\nadd: Added the credits roll\n/:cl:", IRCNick = "Cybereye", IRCAnnouncer = "ZBot", IRCChannel = "#devbus", IRCServer = "irc.rizon.net", RepoOwner = "tgstation", Repo = "tgstation", BaseBranch = "master", ForkOwner = "Cyberboss", Branch = "Credits", InfoStr = "Cyberboss-secret";
Thread ListenerThread;
static void Main() => Run(new Program());
protected override void OnStart(string[] args)
{
ListenerThread = new Thread(new ThreadStart(Listen));
ListenerThread.Start();
}
protected override void OnStop()
{
try
{
client.RfcQuit();
client.Disconnect();
}
catch { }
ListenerThread.Abort();
ListenerThread.Join();
}
private void Listen()
{
if (Properties.Settings.Default.MyJobIsDone)
return;
while (true)
{
try
{
client = new IrcFeatures()
{
ActiveChannelSyncing = true,
AutoReconnect = true,
AutoRejoin = true,
AutoRejoinOnKick = true,
AutoRelogin = true,
AutoRetry = true,
CtcpVersion = InfoStr,
SupportNonRfc = true,
};
client.OnChannelMessage += Client_OnChannelMessage;
client.Connect(IRCServer, ServerPort);
client.Login(IRCNick, IRCNick);
client.RfcJoin(IRCChannel);
client.Listen();
Thread.Sleep(10000);
}
catch (ThreadAbortException)
{
return;
}
catch { }
}
}
private void Client_OnChannelMessage(object sender, IrcEventArgs e)
{
if (e.Data.Channel == IRCChannel && e.Data.Nick == IRCAnnouncer && e.Data.Message.Contains(String.Format("#{0}", target_pr - 1)))
ActivateTheDroids();
}
private void ActivateTheDroids()
{
var gclient = new GitHubClient(new ProductHeaderValue(InfoStr));
var tokenAuth = new Credentials("9655d23cad358d581450ed7a466476c36cb239f5");
gclient.Credentials = tokenAuth;
var pr = new NewPullRequest(PRName, ForkOwner + ":" + Branch, BaseBranch)
{
Body = PRDesc
};
gclient.PullRequest.Create(RepoOwner, Repo, pr).Wait();
client.RfcJoin("#coderbus");
client.SendMessage(SendType.Message, "#coderbus", "HA! GOTEEM!");
Properties.Settings.Default.MyJobIsDone = true;
Properties.Settings.Default.Save();
Stop();
}
}
}
using System.ComponentModel;
using System.Configuration.Install;
namespace OpenPRWhenIssueNIsReached
{
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
public ProjectInstaller()
{
Installers.AddRange(new Installer[] {
new System.ServiceProcess.ServiceProcessInstaller()
{
Account = System.ServiceProcess.ServiceAccount.LocalSystem
},
new System.ServiceProcess.ServiceInstaller()
{
DelayedAutoStart = true,
Description = "Gets PR 30k",
DisplayName = "PR Opener",
ServiceName = "PR Opener",
StartType = System.ServiceProcess.ServiceStartMode.Automatic,
}});
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpenPRWhenIssueNIsReached.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool MyJobIsDone {
get {
return ((bool)(this["MyJobIsDone"]));
}
set {
this["MyJobIsDone"] = value;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="OpenPRWhenIssueNIsReached.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="MyJobIsDone" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment