mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-05 21:17:43 -05:00
Support loginfilter in chat plugins
This commit is contained in:
parent
83632c0789
commit
784147e9a3
8
chat.js
8
chat.js
|
|
@ -166,6 +166,12 @@ Chat.hostfilter = function (host, user, connection) {
|
|||
filter(host, user, connection);
|
||||
}
|
||||
};
|
||||
Chat.loginfilters = [];
|
||||
Chat.loginfilter = function (user, oldUser, usertype) {
|
||||
for (const filter of Chat.loginfilters) {
|
||||
filter(user, oldUser, usertype);
|
||||
}
|
||||
};
|
||||
|
||||
/*********************************************************
|
||||
* Parser
|
||||
|
|
@ -977,6 +983,7 @@ Chat.loadPlugins = function () {
|
|||
if (Config.chatfilter) Chat.filters.push(Config.chatfilter);
|
||||
if (Config.namefilter) Chat.namefilters.push(Config.namefilter);
|
||||
if (Config.hostfilter) Chat.hostfilters.push(Config.hostfilter);
|
||||
if (Config.loginfilter) Chat.loginfilters.push(Config.loginfilter);
|
||||
|
||||
// Install plug-in commands and chat filters
|
||||
|
||||
|
|
@ -994,6 +1001,7 @@ Chat.loadPlugins = function () {
|
|||
if (plugin.chatfilter) Chat.filters.push(plugin.chatfilter);
|
||||
if (plugin.namefilter) Chat.namefilters.push(plugin.namefilter);
|
||||
if (plugin.hostfilter) Chat.hostfilters.push(plugin.hostfilter);
|
||||
if (plugin.loginfilter) Chat.loginfilters.push(plugin.loginfilter);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
4
users.js
4
users.js
|
|
@ -762,14 +762,14 @@ class User {
|
|||
if (user.namelocked) user.named = true;
|
||||
|
||||
Rooms.global.checkAutojoin(user);
|
||||
if (Config.loginfilter) Config.loginfilter(user, this, userType);
|
||||
Chat.loginfilter(user, this, userType);
|
||||
return true;
|
||||
}
|
||||
|
||||
// rename success
|
||||
if (this.forceRename(name, registered)) {
|
||||
Rooms.global.checkAutojoin(this);
|
||||
if (Config.loginfilter) Config.loginfilter(this, null, userType);
|
||||
Chat.loginfilter(this, null, userType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user