Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SocraticPhoenix committed Nov 1, 2017
1 parent 2c5ca08 commit adf71a1
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
String content = cmdContent.length > 1 ? cmdContent[1] : null;

if (cmd.equals("run")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

String[] langContent = content.split(" ", 2);
if (!sessions.containsKey(id)) {
String lang = langContent[0];
Expand Down Expand Up @@ -65,6 +70,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send(handle + " already has a session. Cancel or submit it to create a new one.");
}
} else if (cmd.equals("arg")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (sessions.containsKey(id)) {
CodeSession session = sessions.get(id);
session.getArgs().add(content);
Expand All @@ -73,6 +83,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send("No session found for " + handle);
}
} else if (cmd.equals("input")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (sessions.containsKey(id)) {
if (sessions.containsKey(id)) {
CodeSession session = sessions.get(id);
Expand All @@ -85,6 +100,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send("No session found for " + handle);
}
} else if (cmd.equals("code")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (sessions.containsKey(id)) {
CodeSession session = sessions.get(id);
session.getCode().append(content).append("\n");
Expand All @@ -93,6 +113,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send("No session found for " + handle);
}
} else if (cmd.equals("flag")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (sessions.containsKey(id)) {
CodeSession session = sessions.get(id);
session.getCmdFlags().add(content);
Expand All @@ -101,6 +126,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send("No session found for " + handle);
}
} else if (cmd.equals("cflag")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (sessions.containsKey(id)) {
CodeSession session = sessions.get(id);
session.getCompFlags().add(content);
Expand All @@ -124,6 +154,11 @@ public void accept(MessagePostedEvent messagePostedEvent) {
room.send("No session found for " + handle);
}
} else if (cmd.equals("session")) {
if (content == null) {
room.send(handle + " expected more arguments...");
return;
}

if (!sessions.containsKey(id)) {
String lang = content;
if (languages.contains(lang)) {
Expand All @@ -143,6 +178,8 @@ public void accept(MessagePostedEvent messagePostedEvent) {
}
} else if (cmd.equals("cancel")) {
sessions.remove(id);
} else if (cmd.equals("help")) {
room.send("[TIOBot command list](https://gist.github.com/SocraticPhoenix/bf98c72d0c1274acce76bc02ac6ee253)");
}
}
}
Expand Down

0 comments on commit adf71a1

Please sign in to comment.