1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-02 09:08:32 +00:00

Clean up the group chat rename code

This commit is contained in:
walle303 2016-12-09 06:14:54 +00:00
parent cb88ac9cac
commit 065d5b552f

View file

@ -449,34 +449,33 @@ FFZ.prototype.get_banned_users = function() {
// Group Chat Renaming // Group Chat Renaming
// --------------------- // ---------------------
FFZ.chat_commands.renamegroup = function(room, args) { FFZ.chat_commands.renamegroup = function(room, args) {
// Get the current room. // Shorten the FFZ instance
var controller = utils.ember_lookup('controller:chat'), var f = this;
room_id = controller.get('currentRoom.id'),
room = this.rooms[room_id],
has_product = false,
f = this;
//Join the arguments and check to see if something was entered // Join the arguments and check to see if something was entered
newname = args.join(' '); var newname = args.join(' ');
if ( encodeURI(newname).split(/%..|./).length-1 == 0 ) { if ( ! newname.length ) {
return "Usage: /renamegroup <name>\nThis command must be used inside a group chat that you are owner of." return "Usage: /renamegroup <name>\nThis command must be used inside a group chat that you are owner of."
} }
//Are we in a group chat and are we the owner? // Are we in a group chat and are we the owner?
if ( ! f.rooms[room_id].room.get('isGroupRoom') ) { if ( ! room.room.get('isGroupRoom') ) {
return "You must be in a group chat to use renamegroup." return "You must be in a group chat to use renamegroup."
} }
if ( ! f.rooms[room_id].room.get('isOwner') ) { if ( ! room.room.get('isOwner') ) {
return "You must be the owner of the current group chat to use renamegroup." return "You must be the owner of the current group chat to use renamegroup."
} }
//Check that the length of the arguments is less than 120 bytes // Check that the length of the arguments is less than 120 bytes
if ( encodeURI(newname).split(/%..|./).length-1 > 120 ) { if ( unescape(encodeURIComponent(newname)).length > 120 ) {
return "You entered a room name that was too long." return "You entered a room name that was too long."
} }
//Set the group name // Set the group name
f.rooms[room_id].room.tmiRoom.session._depotApi.put("/rooms/"+[room_id],{display_name:newname}) room.room.tmiRoom.session._depotApi.put(
"/rooms/" + room.id,
{display_name:newname}
)
} }
/*FFZ.ffz_commands.massunban = function(room, args) { /*FFZ.ffz_commands.massunban = function(room, args) {