Fixed input
This commit is contained in:
parent
a3d34fbec2
commit
8278b4cc55
18
HxBot.hx
18
HxBot.hx
@ -1,11 +1,9 @@
|
|||||||
// Haxe RawBot v1.0
|
// Haxe RawBot v1.1
|
||||||
// Connects to IRC and joins #lobby
|
// Attempts to catch connection loss
|
||||||
//
|
|
||||||
// Issues:
|
|
||||||
// - Does not detect connection loss
|
|
||||||
|
|
||||||
import sys.net.Host;
|
import sys.net.Host;
|
||||||
import sys.net.Socket;
|
import sys.net.Socket;
|
||||||
|
using StringTools;
|
||||||
|
|
||||||
class HxBot {
|
class HxBot {
|
||||||
public static function main() {
|
public static function main() {
|
||||||
@ -19,6 +17,7 @@ class HxBot {
|
|||||||
Sys.println("");
|
Sys.println("");
|
||||||
|
|
||||||
var irc = new Socket();
|
var irc = new Socket();
|
||||||
|
// Need to put a try-catch in here probably
|
||||||
irc.connect(server, port);
|
irc.connect(server, port);
|
||||||
|
|
||||||
irc.write('NICK ${Std.string(botnick)}\n');
|
irc.write('NICK ${Std.string(botnick)}\n');
|
||||||
@ -32,10 +31,7 @@ class HxBot {
|
|||||||
|
|
||||||
// Main program loop
|
// Main program loop
|
||||||
while (true) {
|
while (true) {
|
||||||
data = Std.string(irc.input.readLine());
|
data = irc.input.readLine(); // The good one
|
||||||
|
|
||||||
// Detect connection loss (from PyBot, not working in Haxe)
|
|
||||||
//if (dataReceived == "b''") {break;}
|
|
||||||
|
|
||||||
Sys.println(data);
|
Sys.println(data);
|
||||||
|
|
||||||
@ -45,6 +41,7 @@ class HxBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Auto-Rejoin when kicked
|
// Auto-Rejoin when kicked
|
||||||
|
// TODO: Make sure this only happens when THIS BOT is kicked!
|
||||||
if (data.indexOf("KICK #") == data.indexOf(" ")+1) {
|
if (data.indexOf("KICK #") == data.indexOf(" ")+1) {
|
||||||
source = data.substring(data.indexOf("#"), data.indexOf(" ", data.indexOf("#")));
|
source = data.substring(data.indexOf("#"), data.indexOf(" ", data.indexOf("#")));
|
||||||
irc.write('JOIN ${source}\r\n');
|
irc.write('JOIN ${source}\r\n');
|
||||||
@ -55,8 +52,7 @@ class HxBot {
|
|||||||
irc.write('QUIT :Shutdown\r\n');
|
irc.write('QUIT :Shutdown\r\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End of program
|
|
||||||
Sys.println("");
|
Sys.println("");
|
||||||
Sys.println('Connection terminated.');
|
Sys.println("Connection terminated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user