Created
August 1, 2015 15:25
-
-
Save kotarou3/353741fd8f1554db1def to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Room Avatar Commands | |
**/ | |
function fakeUnrecognized() { | |
var fullCmd = this.namespaces.concat(this.cmd).join(' '); | |
if (this.cmdToken === '!') { | |
return this.errorReply("The command '" + this.cmdToken + fullCmd + "' was unrecognized."); | |
} | |
return this.errorReply("The command '" + this.cmdToken + fullCmd + "' was unrecognized. To send a message starting with '" + this.cmdToken + fullCmd + "', type '" + this.cmdToken.repeat(2) + fullCmd + "'."); | |
} | |
var baseWhois = require('./../chat-plugins/info').commands.whois; | |
exports.commands = { | |
spammode: function (target, room, user) { | |
if (!this.can('ban')) return false; | |
// NOTE: by default, spammode does nothing; it's up to you to set stricter filters | |
// in config for chatfilter/hostfilter. Put this above the spammode filters: | |
/* | |
if (!Config.spammode) return; | |
if (Config.spammode < Date.now()) { | |
delete Config.spammode; | |
return; | |
} | |
*/ | |
if (!target) { | |
if (!this.canBroadcast()) return; | |
if (Config.spammode < Date.now()) { | |
delete Config.spammode; | |
} | |
if (Config.spammode) { | |
var expiration = Math.round((Config.spammode - Date.now()) / 1000 / 60); | |
this.sendReply("Spammode is currently set to: " + (Config.spammodehosts[Config.spammodehost] || "ALL") + " (expires in " + expiration + " minutes)"); | |
} else { | |
this.sendReply("Spammode is currently set to: OFF"); | |
} | |
if (!this.broadcasting) this.sendReply("/spammode requires the username of an evader now"); | |
return; | |
} | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) { | |
this.sendReply("User '" + this.targetUsername + "' not found."); | |
this.sendReply("/spammode requires the username of an evader now"); | |
return; | |
} | |
var host = Users.shortenHost(targetUser.latestHost); | |
if (host.slice(-14) === 'unknown-nohost') host = 'unknown-nohost'; | |
if (!Config.spammodehosts[host]) { | |
this.sendReply("User '" + this.targetUsername + "' is not using a host blocked by spammode."); | |
return; | |
} | |
if (Config.spammode) { | |
if (host !== Config.spammodehost) { | |
Config.spammodehost = true; | |
} | |
Rooms.rooms.staff.add("" + user.name + " renewed spammode " + (Config.spammodehosts[Config.spammodehost] || 'ALL') + " for half an hour."); | |
} else { | |
Config.spammodehost = host; | |
Rooms.rooms.staff.add("" + user.name + " turned on spammode " + (Config.spammodehosts[Config.spammodehost] || 'ALL') + " for half an hour."); | |
} | |
Config.spammode = Date.now() + 30 * 60 * 1000; | |
}, | |
spammodehelp: ["/spammode [user] - turns on spammode for an evader user"], | |
spammodeoff: function (target, room, user) { | |
if (Config.spammode) { | |
delete Config.spammode; | |
Rooms.rooms.staff.add("" + user.name + " turned spammode OFF."); | |
} else { | |
this.sendReply("Spammode is already off."); | |
} | |
}, | |
bofrocket: function (target, room, user) { | |
if (room.id !== 'bof') return fakeUnrecognized.call(this); | |
if (!this.can('modchat', null, room)) return; | |
target = this.splitTarget(target); | |
if (!this.targetUser) return this.sendReply("User not found"); | |
if (!room.users[this.targetUser.userid]) return this.sendReply("Not in bof"); | |
this.targetUser.avatar = '#bofrocket'; | |
room.add("" + user.name + " applied bofrocket to " + this.targetUser.name); | |
}, | |
showtan: function (target, room, user) { | |
if (room.id !== 'showderp') return fakeUnrecognized.call(this); | |
if (!this.can('modchat', null, room)) return; | |
target = this.splitTarget(target); | |
if (!this.targetUser) return this.sendReply("User not found"); | |
if (!room.users[this.targetUser.userid]) return this.sendReply("Not a showderper"); | |
this.targetUser.avatar = '#showtan'; | |
room.add("" + user.name + " applied showtan to affected area of " + this.targetUser.name); | |
}, | |
cpgtan: function (target, room, user) { | |
if (room.id !== 'cpg') return fakeUnrecognized.call(this); | |
if (!this.can('modchat', null, room)) return; | |
target = this.splitTarget(target); | |
if (!this.targetUser) return this.sendReply("User not found"); | |
if (!room.users[this.targetUser.userid]) return this.sendReply("Not a cpger"); | |
this.targetUser.avatar = '#cpgtan'; | |
room.add("" + user.name + " applied cpgtan to affected area of " + this.targetUser.name); | |
}, | |
soku: function (target, room, user, connection) { | |
if (room.id !== 'yuyukofanclub') return fakeUnrecognized.call(this); | |
if (!target) return this.parse('/soku help'); | |
var targetCmdIndex = target.indexOf(' '); | |
var targetCmd = targetCmdIndex >= 0 ? target.slice(0, targetCmdIndex) : target.slice(0); | |
target = targetCmdIndex >= 0 ? target.slice(targetCmdIndex).trim() : ''; | |
switch (targetCmd) { | |
case 'help': | |
this.sendReplyBox( | |
"/soku host [port] - Host a game of Hisoutensoku.<br />" | |
); | |
break; | |
case 'host': | |
if (!this.can('broadcast', null, room)) return false; | |
if ((user.locked || room.isMuted(user)) && !user.can('bypassall')) return this.sendReply("You cannot do this while unable to talk."); | |
var ip = '' + connection.ip + ':' + (target || 10800); | |
room.add("" + user.name + " is hosting at " + ip); | |
break; | |
default: | |
return this.parse('/soku help'); | |
} | |
}, | |
s1searchall: 's1search', | |
s1search: function (target, room, user, connection, cmd) { | |
if (user.group !== '~') return fakeUnrecognized.call(this); | |
if (!target.trim()) return this.parse('/help s1search'); | |
var results = []; | |
var isAll = (cmd === 's1searchall'); | |
if (/[0-9a-f-]/.test(target)) { | |
var targets = target.split('-'); | |
var s1 = targets[0]; | |
var s2 = targets[1]; | |
var s3 = targets[2]; | |
var s4 = targets[3]; | |
this.sendReply("Users with s1 " + target + ":"); | |
for (var userid in Users.users) { | |
var curUser = Users.users[userid]; | |
if (s1 && curUser.s1 !== s1) continue; | |
if (s2 && curUser.s2 !== s2) continue; | |
if (s3 && curUser.s3 !== s3) continue; | |
if (s4 === 'nonus') { | |
if (Users.shortenHost(curUser.latestHost) in Config.usahosts) continue; | |
} else if (s4) { | |
if (Users.shortenHost(curUser.latestHost) !== s4) continue; | |
} | |
if (results.push((curUser.connected ? " \u25C9 " : " \u25CC ") + " " + curUser.name) > 100 && !isAll) { | |
return this.sendReply("More than 100 users match the specified IP range. Use /s1searchall to retrieve the full list."); | |
} | |
} | |
} | |
if (!results.length) return this.sendReply("No results found."); | |
return this.sendReply(results.join('; ')); | |
}, | |
sget: function (target, room, user) { | |
if (user.group !== '~') return fakeUnrecognized.call(this); | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) return this.sendReply("User not found"); | |
this.sendReply("" + targetUser.name + ": " + targetUser.s1 + "-" + targetUser.s2 + "-" + targetUser.s3); | |
}, | |
allowname: function (target, room, user) { | |
if (" +".includes(user.group)) return fakeUnrecognized.call(this); | |
target = toId(target); | |
Config.namefilterwhitelist[target] = user.name; | |
Rooms.rooms.staff.add("'" + target + "' was allowed as a username by " + user.name + "."); | |
Rooms.rooms.staff.update(); | |
Rooms.rooms.upperstaff.add("'" + target + "' was allowed as a username by " + user.name + "."); | |
Rooms.rooms.upperstaff.update(); | |
}, | |
patrol: function (target, room, user) { | |
if (user.group !== '~') return fakeUnrecognized.call(this); | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) return this.sendReply("User not found"); | |
if (targetUser.patrolled) return this.sendReply("User already patrolled"); | |
targetUser.patrolled = '#' + user.userid; | |
this.sendReply("Patrol on: " + targetUser.name); | |
}, | |
unpatrol: function (target, room, user) { | |
if (user.group !== '~') return fakeUnrecognized.call(this); | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) return this.sendReply("User not found"); | |
if (!targetUser.patrolled) return this.sendReply("User not patrolled"); | |
targetUser.patrolled = ''; | |
this.sendReply("Patrol off: " + targetUser.name); | |
}, | |
shadowban: function (target, room, user) { | |
if (" +".includes(user.group)) return fakeUnrecognized.call(this); | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) return this.sendReply("User not found"); | |
if (!"~&".includes(user.group) && !targetUser.locked) { | |
return this.sendReply("Only upper staff can shadowban unlocked users."); | |
} | |
if (targetUser.shadowBanned) return this.sendReply("User already shadowbanned"); | |
targetUser.shadowBanned = '#' + user.userid; | |
Rooms.rooms.staff.add("" + (targetUser.locked ? "‽" : "") + targetUser.name + " was shadowbanned by " + user.name + (target ? " (" + target + ")" : "") + "."); | |
this.globalModlog('SHADOWBAN', targetUser, " by " + user.name + (target ? ": " + target : "")); | |
Rooms.rooms.staff.update(); | |
}, | |
unshadowban: function (target, room, user) { | |
if (" +".includes(user.group)) return fakeUnrecognized.call(this); | |
target = this.splitTarget(target); | |
var targetUser = this.targetUser; | |
if (!targetUser) return this.sendReply("User not found"); | |
if (!targetUser.shadowBanned) return this.sendReply("User not shadowbanned"); | |
targetUser.shadowBanned = false; | |
room.add("" + targetUser.name + " was unshadowbanned by " + user.name + "."); | |
}, | |
whois: function (target, room, user) { | |
baseWhois.apply(this, arguments); | |
if (this.targetUser && this.targetUser.shadowBanned && user.can('lock')) { | |
this.sendReplyBox('Shadowbanned: ' + this.targetUser.shadowBanned); | |
} | |
}, | |
ban: function (target, room, user) { | |
if (CommandParser.baseCommands.ban.apply(this, arguments)) { | |
if (!Users.s1track) Users.s1track = Object.create(null); | |
if (this.targetUser.s1) { | |
Users.s1track[this.targetUser.s1] = (this.targetUser.locked || this.targetUser.userid); | |
} | |
} | |
}, | |
lock: function (target, room, user) { | |
if (CommandParser.baseCommands.lock.apply(this, arguments)) { | |
if (!Users.s1track) Users.s1track = Object.create(null); | |
if (this.targetUser.s1) { | |
Users.s1track[this.targetUser.s1] = (this.targetUser.locked || this.targetUser.userid); | |
} | |
} | |
}, | |
forcerename: function (target, room, user) { | |
if (CommandParser.baseCommands.forcerename.apply(this, arguments)) { | |
this.targetUser.trackRename = target; | |
} | |
} | |
}; | |
function untracks1(userid) { | |
if (!Users.s1track) Users.s1track = Object.create(null); | |
for (var s1 in Users.s1track) { | |
if (Users.s1track[s1] === userid) delete Users.s1track[s1]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment