#1 Handle topic saving in Channel Settings

master
Tomatix 3 years ago
parent 8e1f1508a0
commit 2ea14bca4b
  1. 43
      ChannelSettings.iis

@ -50,7 +50,10 @@ menu channel
showmessage("Not connected", "You are not connected to the server", "warn", "o"); showmessage("Not connected", "You are not connected to the server", "warn", "o");
return; return;
} }
channelOrig = channel;
channel = strlower(channel);
if (chansethndl[channel] != void && dlgvalidhndl(chansethndl[channel])) if (chansethndl[channel] != void && dlgvalidhndl(chansethndl[channel]))
dlgclose(chansethndl[channel]); dlgclose(chansethndl[channel]);
@ -71,7 +74,7 @@ menu channel
# Custom attribute to keep track of which channel the dialog has an effect to # Custom attribute to keep track of which channel the dialog has an effect to
dlgsetattr(hndl, "channel", channel); dlgsetattr(hndl, "channel", channel);
dlgsetattr(hndl, "title", "Settings for " + channel); dlgsetattr(hndl, "title", "Settings for " + channelOrig);
dlgsetwidgetattr(hndl, "bantable", "header", list("Mask", "Set by", "Date")); dlgsetwidgetattr(hndl, "bantable", "header", list("Mask", "Set by", "Date"));
@ -104,7 +107,8 @@ menu channel
hook numeric(code, params, message) hook numeric(code, params, message)
{ {
channel = params[1]; channel = strlower(params[1]);
if (channel == void) if (channel == void)
return; return;
@ -113,9 +117,10 @@ hook numeric(code, params, message)
hndl = chansethndl[channel]; hndl = chansethndl[channel];
# No topic is set. # No topic is set
if (code == "331") { if (code == "331") {
topicDone[channel] = true; topicDone[channel] = true;
currentTopic[channel] = "";
} }
# Topic received # Topic received
@ -124,11 +129,12 @@ hook numeric(code, params, message)
topicDone[channel] = true; topicDone[channel] = true;
currentTopic[channel] = message; currentTopic[channel] = message;
} }
# Topic-by message is always a bit late to the party so must be unmuted separately.
else if (code == "333") { else if (code == "333") {
/unmuteresp 333 /unmuteresp 333
} }
# Mode list received # Mode list received
else if (code == "324") { else if (code == "324") {
args = list(); args = list();
@ -144,7 +150,7 @@ hook numeric(code, params, message)
# Ban list item received # Ban list item received
else if (code == "367") { else if (code == "367") {
handle = chansethndl[params[1]]; handle = chansethndl[channel];
mask = params[2]; mask = params[2];
setby = params[3]; setby = params[3];
@ -160,7 +166,7 @@ hook numeric(code, params, message)
# Invites list item received # Invites list item received
else if (code == "346") { else if (code == "346") {
handle = chansethndl[params[1]]; handle = chansethndl[channel];
mask = params[2]; mask = params[2];
setby = params[3]; setby = params[3];
@ -176,7 +182,7 @@ hook numeric(code, params, message)
# Exceptions list item received # Exceptions list item received
else if (code == "348") { else if (code == "348") {
handle = chansethndl[params[1]]; handle = chansethndl[channel];
mask = params[2]; mask = params[2];
setby = params[3]; setby = params[3];
@ -199,6 +205,7 @@ hook numeric(code, params, message)
# #
hook mode(sender, target, modes) hook mode(sender, target, modes)
{ {
target = strlower(target);
if (chansethndl[target] == void) if (chansethndl[target] == void)
return; return;
handle = chansethndl[target]; handle = chansethndl[target];
@ -274,6 +281,8 @@ function findAndRemoveFromTable(handle, table, mask)
# #
function checkAndHandleAllDone(channel) function checkAndHandleAllDone(channel)
{ {
channel = strlower(channel);
if ((topicDone[channel] == false) if ((topicDone[channel] == false)
|| (modesDone[channel] == false) || (modesDone[channel] == false)
|| (bansDone[channel] == false) || (bansDone[channel] == false)
@ -293,6 +302,8 @@ function checkAndHandleAllDone(channel)
# #
function parseChannelModes(channel, modes, args) function parseChannelModes(channel, modes, args)
{ {
channel = strlower(channel);
hndl = chansethndl[channel]; hndl = chansethndl[channel];
i = 0; i = 0;
argi = 0; # Index of 'args', increments on group B and C. argi = 0; # Index of 'args', increments on group B and C.
@ -658,9 +669,19 @@ dialog channelsettings
height = 25; height = 25;
hook clicked => { hook clicked => {
channel = dlggetattr(handle, "channel"); channel = dlggetattr(handle, "channel");
newModes = createModeDiff(channel);
newModes = createModeDiff(channel);
if (strlen(newModes) > 0) if (strlen(newModes) > 0)
/mode %channel %newModes /mode %channel %newModes
newTopic = dlggetwidgetattr(handle, "topic", "text");
if (newTopic != currentTopic[channel]) {
if (newTopic == "")
/topic -c %channel
else
/topic %channel %newTopic
}
dlgclose(handle); dlgclose(handle);
} }
} }
@ -672,6 +693,8 @@ dialog channelsettings
# #
function createModeDiff(channel) function createModeDiff(channel)
{ {
channel = strlower(channel);
hndl = chansethndl[channel]; hndl = chansethndl[channel];
unsetmodes = ""; unsetmodes = "";

Loading…
Cancel
Save