Added /j /p /w and ctcpreply hook for TIME.

master
Tomatix 4 years ago
parent 856b18d60c
commit bdc2f56593
  1. 127
      Essentials.iis

@ -3,12 +3,64 @@
# (Map) Used if we try to ban someone but we haven't registered their hostname yet. # (Map) Used if we try to ban someone but we haven't registered their hostname yet.
global banqueue, kickqueue; global banqueue, kickqueue;
command j(channel, key)
{
if (channel == void) {
/echo Usage: /j channel
return;
}
if (channel[0] != "#")
channel = "#" + channel;
if (key == void)
/join %channel
else
/join %channel %key
}
command p(channel, message)
{
if (channel == void) {
if (subwintype() == "Channel") {
channel = subwinname();
}
else {
/echo -G /p: Not in a channel. Try /p channel
return;
}
}
if (channel[0] != "#")
channel = "#" + channel;
if (message == void)
/part %channel
else
/part %channel %message
}
command w(nickname) /whois %nickname
hook ctcprequest(sender, target, command, message)
{
# For simplicity, set following to "false" if this is undesirable:
response_CTCP_TIME = true;
/echo ctcp: %sender %target %command %message
if (command == "TIME" && response_CTCP_TIME) {
t = now("yyyy/MM/dd hh:mm:ss t");
/ctcpreply %sender TIME %t
}
}
hook start() hook start()
{ {
# Queue for host lookup if a ban is issued, but hostname is unknown. # Queue for host lookup if a ban is issued, but hostname is unknown.
# Key: nickname, Value: channel to issue ban. # Key: nickname, Value: channel to issue ban.
banqueue = map(); banqueue = map();
# Same as above, but value is the kick reason. # Same as above, but value is the kick reason.
kickqueue = map(); kickqueue = map();
} }
@ -84,9 +136,9 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
divide divide
"Privileges" { "Privileges" {
"Give op" => privilege(channel, "+", "o", selected); "Give op" => privilege(channel, "+", "o", selected);
"Take op" => privilege(channel, "-", "o", selected); "Take op" => privilege(channel, "-", "o", selected);
@ -97,9 +149,9 @@ menu memberlist {
"Give voice" => privilege(channel, "+", "v", selected); "Give voice" => privilege(channel, "+", "v", selected);
"Take voice" => privilege(channel, "-", "v", selected); "Take voice" => privilege(channel, "-", "v", selected);
} }
divide divide
"Kick..." => { "Kick..." => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -118,7 +170,7 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
"Ban" => { "Ban" => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -141,7 +193,7 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
"Ban + kick..." => { "Ban + kick..." => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -170,9 +222,9 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
divide divide
"CTCP" { "CTCP" {
"Ping" => { "Ping" => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
@ -189,7 +241,7 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
"Version" => { "Version" => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -205,7 +257,7 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
"Time" => { "Time" => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -221,9 +273,9 @@ menu memberlist {
i = i + 1; i = i + 1;
} }
} }
divide divide
"Custom..." => { "Custom..." => {
if (maplen(selected) > 1) { if (maplen(selected) > 1) {
button = showmessage("Multiple members selected", button = showmessage("Multiple members selected",
@ -244,6 +296,10 @@ menu memberlist {
} }
} }
#
# Used as a callback when trying to ban someone we don't know the hostname of,
# and this numeric responds with a hostname to ban.
#
hook numeric(code, args, msg) hook numeric(code, args, msg)
{ {
if (code == "302") { if (code == "302") {
@ -252,18 +308,18 @@ hook numeric(code, args, msg)
# as an Operator. The '-' or '+' characters represent # as an Operator. The '-' or '+' characters represent
# whether the client has set an AWAY message or not # whether the client has set an AWAY message or not
# respectively. # respectively.
nickend = strfind(msg, "="); nickend = strfind(msg, "=");
if (msg[nickend - 1] == "*") nickend = nickend - 1; if (msg[nickend - 1] == "*") nickend = nickend - 1;
nickname = strmid(msg, 0, nickend); nickname = strmid(msg, 0, nickend);
if (banqueue[nickname] != void) { if (banqueue[nickname] != void) {
channel = banqueue[nickname]; channel = banqueue[nickname];
mapremove(&banqueue, nickname); mapremove(&banqueue, nickname);
host = userhost(nickname); host = userhost(nickname);
/mode %channel +b %host /mode %channel +b %host
if (kickqueue[nickname] != void) { if (kickqueue[nickname] != void) {
reason = kickqueue[nickname]; reason = kickqueue[nickname];
mapremove(&kickqueue, nickname); mapremove(&kickqueue, nickname);
@ -280,24 +336,23 @@ hook numeric(code, args, msg)
# #
function privilege(channel, action, mode, members) function privilege(channel, action, mode, members)
{ {
maxmodes = toint(isupport("MODES")); maxmodes = toint(isupport("MODES"));
totalmodes = maplen(&members); totalmodes = maplen(&members);
i = 0; i = 0;
while (i < totalmodes) { while (i < totalmodes) {
modelen = maxmodes; modelen = maxmodes;
if ((totalmodes - i) < maxmodes) if ((totalmodes - i) < maxmodes)
modelen = totalmodes - i; modelen = totalmodes - i;
j = i;
nicks = "";
while (j < (i + modelen)) {
nicks = nicks + members[j] + " ";
j = j + 1;
}
modestr = action + strrep(mode, modelen);
/mode %channel %modestr %nicks
i = i + modelen;
}
j = i;
nicks = "";
while (j < (i + modelen)) {
nicks = nicks + members[j] + " ";
j = j + 1;
}
modestr = action + strrep(mode, modelen);
/mode %channel %modestr %nicks
i = i + modelen;
}
} }

Loading…
Cancel
Save