Skip to content
Snippets Groups Projects
Commit 1fec0d45 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix irc.js line 750: TypeError: channels.current is undefined

And other potential occurrences of this when not in a channel
parent 63537730
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -664,6 +664,14 @@ function wait_for(commands) { ...@@ -664,6 +664,14 @@ function wait_for(commands) {
} }
} }
function in_a_channel() {
if(channels.current==undefined) {
screen.print_line("\x01H\x01RYou are not in a channel!\x01N\x01W");
return false;
}
return true;
}
function send_command(command,param) { function send_command(command,param) {
var params=[null]; var params=[null];
var send_to=null; var send_to=null;
...@@ -705,10 +713,7 @@ function send_command(command,param) { ...@@ -705,10 +713,7 @@ function send_command(command,param) {
channels.join(param); channels.join(param);
break; break;
case "ME": case "ME":
if(channels.current==undefined) { if(in_a_channel()) {
screen.print_line("\x01H\x01RYou are not in a channel!\x01N\x01W");
}
else {
channels.current.send("\x01ACTION "+param+"\x01"); channels.current.send("\x01ACTION "+param+"\x01");
screen.print_line("\x01N\x01B*\x01W "+nick+" "+param); screen.print_line("\x01N\x01B*\x01W "+nick+" "+param);
} }
...@@ -723,7 +728,8 @@ function send_command(command,param) { ...@@ -723,7 +728,8 @@ function send_command(command,param) {
case "PART": case "PART":
// If the user specifies a channel, this SHOULD part that channel, // If the user specifies a channel, this SHOULD part that channel,
// not the current one. // not the current one.
channels.part(channels.current.name,param); if(in_a_channel())
channels.part(channels.current.name,param);
break; break;
case "N": case "N":
case "NEXT": case "NEXT":
...@@ -743,19 +749,23 @@ function send_command(command,param) { ...@@ -743,19 +749,23 @@ function send_command(command,param) {
screen.update_statline(); screen.update_statline();
break; break;
case "TOPIC": case "TOPIC":
if (param.substr(0,1) == '#' || param.substr(0,1) == '&') { if(in_a_channel()) {
send_cmd(command, param); if (param.substr(0,1) == '#' || param.substr(0,1) == '&') {
} send_cmd(command, param);
else { }
send_cmd(command, channels.current.name+" "+param); else {
send_cmd(command, channels.current.name+" "+param);
}
} }
break; break;
case "KICK": case "KICK":
if (param.substr(0,1) == '#' || param.substr(0,1) == '&') { if(in_a_channel()) {
send_cmd(command, param); if (param.substr(0,1) == '#' || param.substr(0,1) == '&') {
} send_cmd(command, param);
else { }
send_cmd(command, channels.current.name+" "+param); else {
send_cmd(command, channels.current.name+" "+param);
}
} }
break; break;
case "QUOTE": case "QUOTE":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment