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.
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()
{
# Queue for host lookup if a ban is issued, but hostname is unknown.
# Key: nickname, Value: channel to issue ban.
banqueue = map();
# Same as above, but value is the kick reason.
kickqueue = map();
}
@ -84,9 +136,9 @@ menu memberlist {
i = i + 1;
}
}
divide
"Privileges" {
"Give op" => privilege(channel, "+", "o", selected);
"Take op" => privilege(channel, "-", "o", selected);
@ -97,9 +149,9 @@ menu memberlist {
"Give voice" => privilege(channel, "+", "v", selected);
"Take voice" => privilege(channel, "-", "v", selected);
}
divide
"Kick..." => {
if (maplen(selected) > 1) {
button = showmessage("Multiple members selected",
@ -118,7 +170,7 @@ menu memberlist {
i = i + 1;
}
}
"Ban" => {
if (maplen(selected) > 1) {
button = showmessage("Multiple members selected",
@ -141,7 +193,7 @@ menu memberlist {
i = i + 1;
}
}
"Ban + kick..." => {
if (maplen(selected) > 1) {
button = showmessage("Multiple members selected",
@ -170,9 +222,9 @@ menu memberlist {
i = i + 1;
}
}
divide
"CTCP" {
"Ping" => {
if (maplen(selected) > 1) {
@ -189,7 +241,7 @@ menu memberlist {
i = i + 1;
}
}
"Version" => {
if (maplen(selected) > 1) {
button = showmessage("Multiple members selected",
@ -205,7 +257,7 @@ menu memberlist {
i = i + 1;
}
}
"Time" => {
if (maplen(selected) > 1) {
button = showmessage("Multiple members selected",
@ -221,9 +273,9 @@ menu memberlist {
i = i + 1;
}
}
divide
"Custom..." => {
if (maplen(selected) > 1) {
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)
{
if (code == "302") {
@ -252,18 +308,18 @@ hook numeric(code, args, msg)
# as an Operator. The '-' or '+' characters represent
# whether the client has set an AWAY message or not
# respectively.
nickend = strfind(msg, "=");
if (msg[nickend - 1] == "*") nickend = nickend - 1;
nickname = strmid(msg, 0, nickend);
if (banqueue[nickname] != void) {
channel = banqueue[nickname];
mapremove(&banqueue, nickname);
host = userhost(nickname);
/mode %channel +b %host
if (kickqueue[nickname] != void) {
reason = kickqueue[nickname];
mapremove(&kickqueue, nickname);
@ -280,24 +336,23 @@ hook numeric(code, args, msg)
#
function privilege(channel, action, mode, members)
{
maxmodes = toint(isupport("MODES"));
totalmodes = maplen(&members);
i = 0;
while (i < totalmodes) {
modelen = maxmodes;
if ((totalmodes - i) < maxmodes)
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;
}
maxmodes = toint(isupport("MODES"));
totalmodes = maplen(&members);
i = 0;
while (i < totalmodes) {
modelen = maxmodes;
if ((totalmodes - i) < maxmodes)
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;
}
}

Loading…
Cancel
Save