Skip to content

Commit 66bfc11

Browse files
committed
Upload basic stuff
1 parent a414c91 commit 66bfc11

6 files changed

Lines changed: 238 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DiscordModNotifiyer.Apis
6+
{
7+
class SteamApi
8+
{
9+
10+
}
11+
}

DiscordModNotifiyer/DiscordModNotifiyer.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<Authors>L. Gmann</Authors>
7+
<Company>First-Coder</Company>
8+
<Copyright>L. Gmann</Copyright>
9+
<PackageProjectUrl>https://first-coder.de/</PackageProjectUrl>
10+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
11+
<FileVersion>1.0.0.0</FileVersion>
12+
<Version>1.0.0</Version>
613
</PropertyGroup>
714

15+
<ItemGroup>
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<None Update="settings.json">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
</ItemGroup>
24+
825
</Project>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Text.RegularExpressions;
4+
5+
namespace DiscordModNotifiyer.Extensions
6+
{
7+
class ConsoleExtensions
8+
{
9+
/// <summary>
10+
/// Set default welcome messages
11+
/// </summary>
12+
public static void ClearConsole()
13+
{
14+
Console.Clear();
15+
16+
//if (string.IsNullOrEmpty(settings.ProxyIp))
17+
//{
18+
// WriteColor(@"[//--Warning------------------------------------------------------]", ConsoleColor.Yellow);
19+
// WriteColor($"[// ProxyIp:] Value is not set", ConsoleColor.Yellow);
20+
// WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.Yellow);
21+
//}
22+
23+
Console.WriteLine(Environment.NewLine);
24+
WriteColor(@"[$$$$$$$$\ $$\ $$\ $$$$$$\ $$\]", ConsoleColor.DarkGreen);
25+
WriteColor(@"[$$ _____|\__| $$ | $$ __$$\ $$ |]", ConsoleColor.DarkGreen);
26+
WriteColor(@"[$$ | $$\ $$$$$$\ $$$$$$$\ $$$$$$\ $$ / \__| $$$$$$\ $$$$$$$ | $$$$$$\ $$$$$$\]", ConsoleColor.DarkGreen);
27+
WriteColor(@"[$$$$$\ $$ |$$ __$$\ $$ _____|\_$$ _|$$$$$$\ $$ | $$ __$$\ $$ __$$ |$$ __$$\ $$ __$$\]", ConsoleColor.DarkGreen);
28+
WriteColor(@"[$$ __| $$ |$$ | \__|\$$$$$$\ $$ | \______|$$ | $$ / $$ |$$ / $$ |$$$$$$$$ |$$ | \__|]", ConsoleColor.DarkGreen);
29+
WriteColor(@"[$$ | $$ |$$ | \____$$\ $$ |$$\ $$ | $$\ $$ | $$ |$$ | $$ |$$ ____|$$ |]", ConsoleColor.DarkGreen);
30+
WriteColor(@"[$$ | $$ |$$ | $$$$$$$ | \$$$$ | \$$$$$$ |\$$$$$$ |\$$$$$$$ |\$$$$$$$\ $$ |]", ConsoleColor.DarkGreen);
31+
WriteColor(@"[\__| \__|\__| \_______/ \____/ \______/ \______/ \_______| \_______|\__|]", ConsoleColor.DarkGreen);
32+
Console.WriteLine(Environment.NewLine);
33+
34+
WriteColor(@"[//--Informationen------------------------------------------------]", ConsoleColor.DarkGreen);
35+
WriteColor($"[// Title:] {Assembly.GetEntryAssembly().GetName().Name}", ConsoleColor.DarkGreen);
36+
WriteColor($"[// Version:] {Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version}", ConsoleColor.DarkGreen);
37+
WriteColor($"[// Autor:] {Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright}", ConsoleColor.DarkGreen);
38+
//WriteColor(@"[//--Exit Codes---------------------------------------------------]", ConsoleColor.DarkGreen);
39+
//WriteColor($"[// 0:] Application successful exited", ConsoleColor.DarkGreen);
40+
//WriteColor($"[// 1:] Supported OS is not given", ConsoleColor.DarkGreen);
41+
//WriteColor($"[// 2:] User has no root permissions", ConsoleColor.DarkGreen);
42+
//WriteColor($"[// 3:] Networksadapters are not set", ConsoleColor.DarkGreen);
43+
//WriteColor(@"[//--Settings-----------------------------------------------------]", ConsoleColor.DarkGreen);
44+
//WriteColor($"[// Call on Networkchange:] {settings.CallOnNetworkchange}", ConsoleColor.DarkGreen);
45+
//WriteColor($"[// Set proxy on Autostart:] {settings.SetProxyOnStartUp}", ConsoleColor.DarkGreen);
46+
//WriteColor($"[// Proxy status:] {status}", ConsoleColor.DarkGreen);
47+
//WriteColor(@"[//--Options------------------------------------------------------]", ConsoleColor.DarkGreen);
48+
//WriteColor($"[// 1:] Toggle \"Call on Networkchange\"", ConsoleColor.DarkGreen);
49+
//WriteColor($"[// 2:] Enable proxy", ConsoleColor.DarkGreen);
50+
//WriteColor($"[// 3:] Disable proxy", ConsoleColor.DarkGreen);
51+
//WriteColor($"[// ESC:] Close application", ConsoleColor.DarkGreen);
52+
WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.DarkGreen);
53+
Console.WriteLine(Environment.NewLine);
54+
55+
//if (string.IsNullOrEmpty(settings.NetworkChangeAdapters))
56+
//{
57+
// WriteColor(@"[//--No Networkadapters-------------------------------------------]", ConsoleColor.DarkRed);
58+
// WriteColor($"[//:] Please insert Networkadapters (\"NetworkChangeAdapters\") in the settings.json", ConsoleColor.DarkRed);
59+
// WriteColor(@"[//---------------------------------------------------------------]", ConsoleColor.DarkRed);
60+
// if (!Debugger.IsAttached)
61+
// {
62+
// Environment.Exit(3);
63+
// }
64+
// else
65+
// {
66+
// Console.WriteLine(Environment.NewLine);
67+
// }
68+
//}
69+
}
70+
71+
72+
/// <summary>
73+
/// Write some coloring console messages for the user
74+
/// https://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net
75+
/// </summary>
76+
/// <param name="message">Message to write</param>
77+
/// <param name="color">ConsoleColor value of the color</param>
78+
public static void WriteColor(string message, ConsoleColor color)
79+
{
80+
var pieces = Regex.Split(message, @"(\[[^\]]*\])");
81+
82+
for (int i = 0; i < pieces.Length; i++)
83+
{
84+
string piece = pieces[i];
85+
86+
if (piece.StartsWith("[") && piece.EndsWith("]"))
87+
{
88+
Console.ForegroundColor = color;
89+
piece = piece.Substring(1, piece.Length - 2);
90+
}
91+
92+
Console.Write(piece);
93+
Console.ResetColor();
94+
}
95+
96+
Console.WriteLine();
97+
}
98+
}
99+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
3+
namespace DiscordModNotifiyer.Models
4+
{
5+
public class Settings
6+
{
7+
public bool CallOnNetworkchange { get; set; }
8+
public string NetworkChangeAdapters { get; set; }
9+
public bool SetProxyOnStartUp { get; set; }
10+
11+
public string UniquePrefixLine { get; set; }
12+
public string UniqueSuffixLine { get; set; }
13+
14+
public string BashPath { get; set; }
15+
public string BashCommandEnable { get; set; }
16+
public string BashCommandDisable { get; set; }
17+
18+
public string ProxyIp { get; set; }
19+
public int Timeout { get; set; }
20+
21+
//public List<FileSettings> Files { get; set; }
22+
}
23+
}

DiscordModNotifiyer/Program.cs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,59 @@
1-
using System;
1+
using DiscordModNotifiyer.Extensions;
2+
using DiscordModNotifiyer.Models;
3+
using Newtonsoft.Json;
4+
using System;
5+
using System.IO;
26

37
namespace DiscordModNotifiyer
48
{
59
class Program
610
{
11+
/// <summary>
12+
/// Global name of the settings file
13+
/// </summary>
14+
private const string SETTINGS_FILENAME = "settings.json";
15+
16+
/// <summary>
17+
/// Settings json file
18+
/// </summary>
19+
public static Settings settings;
20+
21+
/// <summary>
22+
/// Constructor
23+
/// </summary>
24+
/// <param name="args"></param>
725
static void Main(string[] args)
826
{
9-
Console.WriteLine("Hello World!");
27+
settings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(SETTINGS_FILENAME));
28+
ConsoleExtensions.ClearConsole();
29+
30+
ConsoleKeyInfo cki;
31+
do
32+
{
33+
cki = Console.ReadKey(true);
34+
35+
switch (cki.KeyChar)
36+
{
37+
case '1':
38+
39+
break;
40+
//case '2':
41+
// Clear();
42+
// EnableProxy();
43+
// break;
44+
//case '3':
45+
// Clear();
46+
// DisableProxy();
47+
// break;
48+
}
49+
} while (cki.Key != ConsoleKey.Escape);
50+
51+
Environment.Exit(0);
1052
}
53+
54+
/// <summary>
55+
/// Reload settings.json file and save them into the settings object
56+
/// </summary>
57+
public static void ReloadSettings() => settings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(SETTINGS_FILENAME));
1158
}
1259
}

DiscordModNotifiyer/settings.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"CallOnNetworkchange": false,
3+
"NetworkChangeAdapters": "<NetworkAdapterName(s) seperate with comma>",
4+
"SetProxyOnStartUp": true,
5+
"UniquePrefixLine": "### Created by LinuxProxyChanger",
6+
"UniqueSuffixLine": "### End of LinuxProxyChanger",
7+
"BashPath": "/bin/bash",
8+
"BashCommandEnable": "source /etc/environment",
9+
"BashCommandDisable": "proxy_http=\nproxys_http=\nproxy_ftp=",
10+
"ProxyIp": "10.1.0.0",
11+
"Timeout": 5,
12+
"Files": [
13+
{
14+
"Path": "/etc/environment",
15+
"Proxy": [
16+
"http_proxy=http://<ProxyIP>:<ProxyPort>/",
17+
"http_proxy=https://<ProxyIP>:<ProxyPort>/",
18+
"ftp_proxy=http://<ProxyIP>:<ProxyPort>/",
19+
"no_proxy=<ProxyExceptions>"
20+
]
21+
},
22+
{
23+
"Path": "/etc/systemd/system/docker.service.d/http-proxy.conf",
24+
"Proxy": [
25+
"[Service]",
26+
"Environment=\"HTTP_PROXY=http://<ProxyIP>:<ProxyPort>\"",
27+
"Environment=\"HTTPS_PROXY=http://<ProxyIP>:<ProxyPort>\"",
28+
"Environment=\"ProxyExceptions>\""
29+
]
30+
},
31+
{
32+
"Path": "/etc/apt/apt.conf.d/proxy.conf",
33+
"Proxy": [
34+
"Acquire::http::Proxy \"http://<ProxyIP>:<ProxyPort>/\";",
35+
"Acquire::https::Proxy \"http://<ProxyIP>:<ProxyPort>/\";"
36+
]
37+
}
38+
]
39+
}

0 commit comments

Comments
 (0)