Local stuff I hadn't committed yet from like a month ago.
This commit is contained in:
parent
3fb853d7b7
commit
7620bf42b2
3 changed files with 116 additions and 25 deletions
29
mikoto.cfg
Normal file
29
mikoto.cfg
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# and ; can be used at the start of a line for comments.
|
||||||
|
|
||||||
|
# General Configuration
|
||||||
|
#chat:port 6770
|
||||||
|
#chat:msgMaxLength 5000
|
||||||
|
#chat:connMaxCount 5
|
||||||
|
#chat:floodKickLength 30
|
||||||
|
chat:floodKickExemptRank 10
|
||||||
|
|
||||||
|
# Channels
|
||||||
|
chat:channels lounge staff
|
||||||
|
|
||||||
|
# Lounge channel settings
|
||||||
|
chat:channels:lounge:name Lounge
|
||||||
|
chat:channels:lounge:autoJoin true
|
||||||
|
|
||||||
|
# Staff channel settings
|
||||||
|
chat:channels:staff:name Staff
|
||||||
|
chat:channels:staff:minRank 5
|
||||||
|
|
||||||
|
# Misuzu integration settings
|
||||||
|
msz:secret veemo57c092d519d6764ebe2afe6207fa403f47885627a61e
|
||||||
|
#msz:url https://flashii.net/_sockchat
|
||||||
|
|
||||||
|
# MariaDB configuration
|
||||||
|
mariadb:host localhost
|
||||||
|
mariadb:user chat
|
||||||
|
mariadb:pass F5o6AVpWYe9K3qQphldxw9NAlpmrINAF
|
||||||
|
mariadb:db chat
|
106
source/app.d
106
source/app.d
|
@ -1,41 +1,25 @@
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import core.thread;
|
import core.thread;
|
||||||
import core.stdc.signal;
|
|
||||||
import core.sys.windows.windows;
|
enum CONFIG_PATH = "mikoto.cfg";
|
||||||
|
|
||||||
__gshared bool hasCancelled;
|
__gshared bool hasCancelled;
|
||||||
|
|
||||||
version(Posix) {
|
|
||||||
extern(C) void signalHander(int num) nothrow @nogc @system {
|
|
||||||
if(num == SIGINT)
|
|
||||||
hasCancelled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
version(Windows) {
|
|
||||||
extern(Windows) BOOL ctrlHandler(DWORD fdwCtrlType) nothrow @nogc @system {
|
|
||||||
switch(fdwCtrlType) {
|
|
||||||
case CTRL_C_EVENT:
|
|
||||||
case CTRL_CLOSE_EVENT:
|
|
||||||
hasCancelled = true;
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
import std.file : exists;
|
||||||
import std.range : padLeft;
|
import std.range : padLeft;
|
||||||
import std.string : format;
|
import std.string : format;
|
||||||
|
|
||||||
version(Windows)
|
version(Windows) {
|
||||||
|
import core.sys.windows.windows : SetConsoleCtrlHandler, TRUE;
|
||||||
if(!SetConsoleCtrlHandler(&ctrlHandler, TRUE))
|
if(!SetConsoleCtrlHandler(&ctrlHandler, TRUE))
|
||||||
stderr.writeln("Failed to register Windows CTRL handler.");
|
stderr.writeln("Failed to register Windows CTRL handler.");
|
||||||
|
}
|
||||||
|
|
||||||
version(Posix)
|
version(Posix) {
|
||||||
|
import core.stdc.signal : signal, SIGINT;
|
||||||
signal(SIGINT, &signalHander);
|
signal(SIGINT, &signalHander);
|
||||||
|
}
|
||||||
|
|
||||||
if(hasCancelled) return;
|
if(hasCancelled) return;
|
||||||
|
|
||||||
|
@ -50,6 +34,13 @@ void main() {
|
||||||
|
|
||||||
if(hasCancelled) return;
|
if(hasCancelled) return;
|
||||||
|
|
||||||
|
string configPath = CONFIG_PATH;
|
||||||
|
|
||||||
|
if(!configPath.exists && configPath == CONFIG_PATH)
|
||||||
|
createExampleConfig(configPath);
|
||||||
|
|
||||||
|
if(hasCancelled) return;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
Thread.sleep(1.seconds);
|
Thread.sleep(1.seconds);
|
||||||
if(hasCancelled)
|
if(hasCancelled)
|
||||||
|
@ -58,3 +49,68 @@ void main() {
|
||||||
|
|
||||||
writeln("Exiting!");
|
writeln("Exiting!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createExampleConfig(string path) {
|
||||||
|
auto cfg = File(path, "wb+");
|
||||||
|
cfg.writeln("# and ; can be used at the start of a line for comments.");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# General Configuration");
|
||||||
|
cfg.writeln(";chat:port {SockChatServer.DEFAULT_PORT}");
|
||||||
|
cfg.writeln(";chat:msgMaxLength {SockChatServer.DEFAULT_MSG_LENGTH_MAX}");
|
||||||
|
cfg.writeln(";chat:connMaxCount {SockChatServer.DEFAULT_MAX_CONNECTIONS}");
|
||||||
|
cfg.writeln(";chat:floodKickLength {SockChatServer.DEFAULT_FLOOD_KICK_LENGTH}");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# Channels");
|
||||||
|
cfg.writeln("chat:channels lounge staff");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# Lounge channel settings");
|
||||||
|
cfg.writeln("chat:channels:lounge:name Lounge");
|
||||||
|
cfg.writeln("chat:channels:lounge:autoJoin true");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# Staff channel settings");
|
||||||
|
cfg.writeln("chat:channels:staff:name Staff");
|
||||||
|
cfg.writeln("chat:channels:staff:minRank 5");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# Misuzu integration settings");
|
||||||
|
cfg.writeln(";msz:secret woomy");
|
||||||
|
cfg.writeln(";msz:url https://flashii.net/_sockchat");
|
||||||
|
|
||||||
|
cfg.writeln();
|
||||||
|
cfg.writeln("# MariaDB configuration");
|
||||||
|
cfg.writeln(";mariadb:host <host>");
|
||||||
|
cfg.writeln(";mariadb:user <username>");
|
||||||
|
cfg.writeln(";mariadb:pass <password>");
|
||||||
|
cfg.writeln(";mariadb:db <database>");
|
||||||
|
}
|
||||||
|
|
||||||
|
version(Posix) {
|
||||||
|
extern(C) void signalHander(int num) nothrow @nogc @system {
|
||||||
|
import core.stdc.signal : SIGINT;
|
||||||
|
|
||||||
|
if(num == SIGINT)
|
||||||
|
hasCancelled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
version(Windows) {
|
||||||
|
import core.sys.windows.windows : BOOL, DWORD;
|
||||||
|
|
||||||
|
extern(Windows) BOOL ctrlHandler(DWORD fdwCtrlType) nothrow @nogc @system {
|
||||||
|
import core.sys.windows.windows : CTRL_C_EVENT, CTRL_CLOSE_EVENT, TRUE, FALSE;
|
||||||
|
|
||||||
|
switch(fdwCtrlType) {
|
||||||
|
case CTRL_C_EVENT:
|
||||||
|
case CTRL_CLOSE_EVENT:
|
||||||
|
hasCancelled = true;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
6
source/config/config.d
Normal file
6
source/config/config.d
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module mikoto.config;
|
||||||
|
|
||||||
|
interface Config {
|
||||||
|
Config scopeTo(string prefix);
|
||||||
|
string readValue(string name, string fallback = null);
|
||||||
|
}
|
Loading…
Reference in a new issue