Bug 180574 - Add /ban and /unban commands.

ChatZilla only.
r=samuel
a=shaver
This commit is contained in:
silver%warwickcompsoc.co.uk 2005-06-02 11:38:18 +00:00
Родитель 3e0b818947
Коммит dcee670150
4 изменённых файлов: 58 добавлений и 13 удалений

Просмотреть файл

@ -2978,6 +2978,15 @@ function usr_hostmask (pfx)
return (pfx + this.host.substr(idx + 1, this.host.length));
}
CIRCUser.prototype.getBanMask =
function usr_banmask()
{
var hostmask = this.host;
if (!/^\d+\.\d+\.\d+\.\d+$/.test(hostmask))
hostmask = hostmask.replace(/^[^.]+/, "*");
return "*!" + this.name + "@" + hostmask;
}
CIRCUser.prototype.say =
function usr_say (msg)
{
@ -3166,7 +3175,7 @@ function cusr_setban (f)
return false;
var modifier = (f) ? " +b " : " -b ";
modifier += this.getHostMask() + " ";
modifier += this.getBanMask() + " ";
server.sendData("MODE " + this.parent.encodedName + modifier + "\n");
@ -3182,7 +3191,7 @@ function cusr_kban (reason)
return false;
reason = (typeof reason != "undefined") ? reason : this.encodedName;
var modifier = " -o+b " + this.encodedName + " " + this.getHostMask() + " ";
var modifier = " -o+b " + this.encodedName + " " + this.getBanMask() + " ";
server.sendData("MODE " + this.parent.encodedName + modifier + "\n" +
"KICK " + this.parent.encodedName + " " +

Просмотреть файл

@ -54,6 +54,7 @@ function initCommands()
["attach", cmdAttach, CMD_CONSOLE],
["away", cmdAway, CMD_CONSOLE],
["back", cmdAway, CMD_CONSOLE],
["ban", cmdBan, CMD_NEED_CHAN | CMD_CONSOLE],
["cancel", cmdCancel, CMD_NEED_NET | CMD_CONSOLE],
["charset", cmdCharset, CMD_CONSOLE],
["channel-motif", cmdMotif, CMD_NEED_CHAN | CMD_CONSOLE],
@ -175,6 +176,7 @@ function initCommands()
["toggle-pref", cmdTogglePref, 0],
["topic", cmdTopic, CMD_NEED_CHAN | CMD_CONSOLE],
["unignore", cmdIgnore, CMD_NEED_NET | CMD_CONSOLE],
["unban", cmdBan, CMD_NEED_CHAN | CMD_CONSOLE],
["unstalk", cmdUnstalk, CMD_CONSOLE],
["urls", cmdURLs, CMD_CONSOLE],
["usermode", cmdUsermode, CMD_CONSOLE],
@ -809,6 +811,38 @@ function cmdAblePlugin(e)
}
}
function cmdBan(e)
{
/* If we're unbanning, or banning in odd cases, we may actually be talking
* about a user who is not in the channel, so we need to check the server
* for information as well.
*/
if (!e.user)
e.user = e.channel.getUser(e.nickname);
if (!e.user)
e.user = e.server.getUser(e.nickname);
var mask;
if (e.user)
{
// We have a real user object, so get their proper 'ban mask'.
mask = e.user.getBanMask();
}
else
{
/* If we have either ! or @ in the nickname assume the user has given
* us a complete mask and pass it directly, otherwise assume it is
* only the nickname and use * for username/host.
*/
mask = fromUnicode(e.nickname, e.server);
if (!/[!@]/.test(e.nickname))
mask = mask + "!*@*";
}
var op = (e.command.name == "unban") ? " -b " : " +b ";
e.server.sendData("MODE " + e.channel.encodedName + op + mask + "\n");
}
function cmdCancel(e)
{
var network = e.network;
@ -2732,17 +2766,7 @@ function cmdKick(e)
}
if (e.command.name == "kick-ban")
{
var hostmask;
if (e.user.host.match(/^[\d\.]*$/) != null)
hostmask = e.user.host.replace(/[^.]+$/, "*");
else
hostmask = e.user.host.replace(/^[^.]+/, "*");
e.server.sendData("MODE " + e.channel.encodedName + " +b *!" +
e.user.name + "@" + hostmask + "\n");
}
e.sourceObject.dispatch("ban", { nickname: e.user.encodedName });
e.user.kick(e.reason);
}

Просмотреть файл

@ -302,6 +302,8 @@ function initMenus()
["voice", {visibleif: isopish + "!cx.user.isVoice"}],
["devoice", {visibleif: isopish + "cx.user.isVoice"}],
["-"],
["ban", {enabledif: "(" + isop + "1) || (" + isopish + "!cx.user.isOp)"}],
["unban", {enabledif: "(" + isop + "1) || (" + isopish + "!cx.user.isOp)"}],
["kick", {enabledif: "(" + isop + "1) || (" + isopish + "!cx.user.isOp)"}],
["kick-ban", {enabledif: "(" + isop + "1) || (" + isopish + "!cx.user.isOp)"}]
]

Просмотреть файл

@ -82,6 +82,11 @@ cmd.back.label = Back
cmd.back.params =
cmd.back.help = Marks you as no longer away.
cmd.ban.label = Ban
cmd.ban.format = Ban from $channelName
cmd.ban.params = <nickname>
cmd.ban.help = Bans a single user, or mask of users, from the current channel. A user's nickname may be specified, or a proper host mask can be used.
cmd.cancel.help = Cancels a /attach or /server command. Use /cancel when ChatZilla is repeatedly trying to attach to a network that is not responding, to tell ChatZilla to give up before the normal number of retries.
cmd.charset.params = [<new-charset>]
@ -368,6 +373,11 @@ cmd.toggle-copy.label = Copy &Important Messages
cmd.toggle-umode.label = Show Mode as Symbol
cmd.toggle-timestamps.label = Show &Timestamps
cmd.unban.label = Un-ban
cmd.unban.format = Un-ban from $channelName
cmd.unban.params = <nickname>
cmd.unban.help = Removes the ban on a single user, or removes a specific ban mask from the channel's ban list.
cmd.userlist.help = Toggles the visibility of the user list.
cmd.ignore.params = [<mask>]