mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-12 14:08:30 +00:00
3.5.176. Ban reason stuff. :D
This commit is contained in:
parent
fbb12d726a
commit
6cf5ddc734
6 changed files with 194 additions and 38 deletions
1
dark.css
1
dark.css
|
@ -987,6 +987,7 @@ body.ffz-dark,
|
||||||
fill: #242424 !important;
|
fill: #242424 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ffz-dark .app-main .chatReplay .noticeWrap,
|
||||||
.ffz-dark .app-main .chatReplay .notice-wrapper {
|
.ffz-dark .app-main .chatReplay .notice-wrapper {
|
||||||
background-color: #191919;
|
background-color: #191919;
|
||||||
}
|
}
|
||||||
|
|
|
@ -860,7 +860,15 @@ FFZ.prototype._modify_chat_subline = function(component) {
|
||||||
classNameBindings: [":message-line", ":chat-line", "msgObject.style", "msgObject.ffz_has_mention:ffz-mentioned", "ffzWasDeleted:ffz-deleted", "ffzHasOldMessages:clearfix", "ffzHasOldMessages:ffz-has-deleted"],
|
classNameBindings: [":message-line", ":chat-line", "msgObject.style", "msgObject.ffz_has_mention:ffz-mentioned", "ffzWasDeleted:ffz-deleted", "ffzHasOldMessages:clearfix", "ffzHasOldMessages:ffz-has-deleted"],
|
||||||
attributeBindings: ["msgObject.room:data-room", "msgObject.from:data-sender", "msgObject.deleted:data-deleted"],
|
attributeBindings: ["msgObject.room:data-room", "msgObject.from:data-sender", "msgObject.deleted:data-deleted"],
|
||||||
|
|
||||||
didInsertElement: function() { this.ffzRender(); },
|
didInsertElement: function() {
|
||||||
|
this.set('msgObject._line', this);
|
||||||
|
this.ffzRender();
|
||||||
|
},
|
||||||
|
|
||||||
|
willClearRender: function() {
|
||||||
|
this.set('msgObject._line', null);
|
||||||
|
},
|
||||||
|
|
||||||
didUpdate: function() { this.ffzRender(); },
|
didUpdate: function() { this.ffzRender(); },
|
||||||
|
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
|
@ -895,7 +903,7 @@ FFZ.prototype._modify_chat_subline = function(component) {
|
||||||
room.send(lines[i], true);
|
room.send(lines[i], true);
|
||||||
|
|
||||||
if ( cl.contains('is-timeout') )
|
if ( cl.contains('is-timeout') )
|
||||||
room.clearMessages(from);
|
room.clearMessages(from, null, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,29 @@ FFZ.settings_info.mod_card_info = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
FFZ.settings_info.timeout_notices = {
|
||||||
|
type: "select",
|
||||||
|
options: {
|
||||||
|
0: "Disabled",
|
||||||
|
1: "If I'm a Moderator",
|
||||||
|
2: "Always"
|
||||||
|
},
|
||||||
|
|
||||||
|
value: 1,
|
||||||
|
process_value: function(val) {
|
||||||
|
if ( typeof val === "string" )
|
||||||
|
return parseInt(val) || 0;
|
||||||
|
return val;
|
||||||
|
},
|
||||||
|
|
||||||
|
no_bttv: true,
|
||||||
|
category: "Chat Moderation",
|
||||||
|
|
||||||
|
name: "Display Timeout / Ban Notices",
|
||||||
|
help: "Display notices in chat when a user is timed out or banned. (You always see your own bans.)"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
FFZ.settings_info.mod_card_history = {
|
FFZ.settings_info.mod_card_history = {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
value: false,
|
value: false,
|
||||||
|
|
|
@ -53,12 +53,12 @@ FFZ.prototype.setup_room = function() {
|
||||||
|
|
||||||
RC._actions.banUser = function(e) {
|
RC._actions.banUser = function(e) {
|
||||||
orig_ban.call(this, e);
|
orig_ban.call(this, e);
|
||||||
this.get("model").clearMessages(e.user);
|
this.get("model").clearMessages(e.user, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
RC._actions.timeoutUser = function(e) {
|
RC._actions.timeoutUser = function(e) {
|
||||||
orig_to.call(this, e);
|
orig_to.call(this, e);
|
||||||
this.get("model").clearMessages(e.user);
|
this.get("model").clearMessages(e.user, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
RC._actions.showModOverlay = function(e) {
|
RC._actions.showModOverlay = function(e) {
|
||||||
|
@ -671,7 +671,8 @@ FFZ.prototype._insert_history = function(room_id, data, from_server) {
|
||||||
if ( ! room || ! room.room )
|
if ( ! room || ! room.room )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var r = room.room,
|
var current_user = this.get_user(),
|
||||||
|
r = room.room,
|
||||||
messages = r.get('messages'),
|
messages = r.get('messages'),
|
||||||
buffer_size = r.get('messageBufferSize'),
|
buffer_size = r.get('messageBufferSize'),
|
||||||
|
|
||||||
|
@ -704,6 +705,18 @@ FFZ.prototype._insert_history = function(room_id, data, from_server) {
|
||||||
if ( f.settings.remove_deleted && msg.deleted )
|
if ( f.settings.remove_deleted && msg.deleted )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if ( msg.tags.target && msg.tags.target !== '@@' ) {
|
||||||
|
var is_mine = current_user && current_user.login === msg.tags.target;
|
||||||
|
if ( ! is_mine && ! r.ffzShouldDisplayNotice() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Display the Ban Reason if we're a moderator or that user.
|
||||||
|
if ( msg.tags['ban-reason'] && is_mine || r.get('isModeratorOrHigher') ) {
|
||||||
|
msg.message = msg.message.substr(0, msg.message.length - 1) + ' with reason: ' + msg.tags['ban-reason'];
|
||||||
|
msg.cachedTokens = [utils.sanitize(msg.message)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( r.shouldShowMessage(msg) && r.ffzShouldShowMessage(msg) ) {
|
if ( r.shouldShowMessage(msg) && r.ffzShouldShowMessage(msg) ) {
|
||||||
if ( messages.length < buffer_size ) {
|
if ( messages.length < buffer_size ) {
|
||||||
if ( msg.ffz_old_messages ) {
|
if ( msg.ffz_old_messages ) {
|
||||||
|
@ -844,17 +857,17 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
|
|
||||||
mru_list: [],
|
mru_list: [],
|
||||||
|
|
||||||
updateWait: function(value, was_banned) {
|
updateWait: function(value, was_banned, update) {
|
||||||
var wait = this.get('slowWait') || 0;
|
var wait = this.get('slowWait') || 0;
|
||||||
this.set('slowWait', value);
|
this.set('slowWait', value);
|
||||||
if ( wait < 1 && value > 0 ) {
|
if ( wait < 1 && value > 0 ) {
|
||||||
if ( this._ffz_wait_timer )
|
if ( this._ffz_wait_timer )
|
||||||
clearTimeout(this._ffz_wait_timer);
|
clearTimeout(this._ffz_wait_timer);
|
||||||
this._ffz_wait_timer = setTimeout(this.ffzUpdateWait.bind(this), 1000);
|
this._ffz_wait_timer = setTimeout(this.ffzUpdateWait.bind(this), 1000);
|
||||||
f._roomv && f._roomv.ffzUpdateStatus();
|
! update && f._roomv && f._roomv.ffzUpdateStatus();
|
||||||
} else if ( (wait > 0 && value < 1) || was_banned ) {
|
} else if ( (wait > 0 && value < 1) || was_banned ) {
|
||||||
this.set('ffz_banned', false);
|
this.set('ffz_banned', false);
|
||||||
f._roomv && f._roomv.ffzUpdateStatus();
|
! update && f._roomv && f._roomv.ffzUpdateStatus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -955,21 +968,53 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clearMessages: function(user) {
|
clearMessages: function(user, tags, disable_log) {
|
||||||
var t = this;
|
var t = this;
|
||||||
if ( user ) {
|
|
||||||
if (!this.ffzRecentlyBanned)
|
|
||||||
this.ffzRecentlyBanned = [];
|
|
||||||
this.ffzRecentlyBanned.push(user);
|
|
||||||
while (this.ffzRecentlyBanned.length > 100)
|
|
||||||
this.ffzRecentlyBanned.shift();
|
|
||||||
|
|
||||||
|
if ( user ) {
|
||||||
|
var duration = undefined,
|
||||||
|
reason = undefined,
|
||||||
|
current_user = f.get_user(),
|
||||||
|
is_me = current_user && current_user.login === user;
|
||||||
|
|
||||||
|
|
||||||
|
// Read the ban duration and reason from the message tags.
|
||||||
|
if ( tags && tags['ban-duration'] )
|
||||||
|
duration = parseInt(tags['ban-duration']);
|
||||||
|
else if ( tags && ! tags.hasOwnProperty('ban-duration') )
|
||||||
|
duration = true;
|
||||||
|
|
||||||
|
if ( tags && tags['ban-reason'] && (is_me || t.get('isModeratorOrHigher')) )
|
||||||
|
reason = tags['ban-reason'];
|
||||||
|
|
||||||
|
|
||||||
|
// If we were banned, set the state and update the UI.
|
||||||
|
if ( is_me ) {
|
||||||
|
t.set('ffz_banned', true);
|
||||||
|
if ( typeof duration === "number" && duration )
|
||||||
|
t.updateWait(duration)
|
||||||
|
else if ( duration ) {
|
||||||
|
t.set('slowWait', 0);
|
||||||
|
f._roomv && f._roomv.ffzUpdateStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Mark the user as recently banned.
|
||||||
|
if ( ! t.ffzRecentlyBanned )
|
||||||
|
t.ffzRecentlyBanned = [];
|
||||||
|
|
||||||
|
t.ffzRecentlyBanned.push(user);
|
||||||
|
while ( t.ffzRecentlyBanned.length > 100 )
|
||||||
|
t.ffzRecentlyBanned.shift();
|
||||||
|
|
||||||
|
|
||||||
|
// Delete Visible Messages
|
||||||
var msgs = t.get('messages'),
|
var msgs = t.get('messages'),
|
||||||
total = msgs.get('length'),
|
total = msgs.get('length'),
|
||||||
i = total,
|
i = total,
|
||||||
removed = 0;
|
removed = 0;
|
||||||
|
|
||||||
// Delete visible messages
|
|
||||||
while(i--) {
|
while(i--) {
|
||||||
var msg = msgs.get(i);
|
var msg = msgs.get(i);
|
||||||
|
|
||||||
|
@ -986,8 +1031,9 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete pending messages
|
|
||||||
if (t.ffzPending) {
|
// Delete Panding Messages
|
||||||
|
if ( t.ffzPending ) {
|
||||||
msgs = t.ffzPending;
|
msgs = t.ffzPending;
|
||||||
i = msgs.length;
|
i = msgs.length;
|
||||||
while(i--) {
|
while(i--) {
|
||||||
|
@ -999,24 +1045,45 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( f.settings.mod_card_history ) {
|
|
||||||
var room = f.rooms && f.rooms[t.get('id')],
|
|
||||||
user_history = room && room.user_history && room.user_history[user]
|
|
||||||
|
|
||||||
if ( user_history !== null && user_history !== undefined ) {
|
// Look up the User's Last Ban
|
||||||
var has_delete = false,
|
// TODO: STUFF and THINGS
|
||||||
last = user_history.length > 0 ? user_history[user_history.length-1] : null;
|
var room = f.rooms && f.rooms[t.get('id')],
|
||||||
|
ban_history, last_ban, identical_ban;
|
||||||
|
|
||||||
has_delete = last !== null && last.is_delete;
|
if ( room ) {
|
||||||
if ( has_delete ) {
|
var now = Date.now();
|
||||||
last.cachedTokens = ['User has been timed out ' + utils.number_commas(++last.deleted_times) + ' times.'];
|
ban_history = room.ban_history = room.ban_history || {};
|
||||||
} else {
|
last_ban = ban_history[user];
|
||||||
user_history.push({from: 'jtv', is_delete: true, style: 'admin', cachedTokens: ['User has been timed out.'], deleted_times: 1, date: new Date()});
|
identical_ban = (now - last_ban[2] >= 1000*(typeof last_ban[0] === "number" ? Math.min(last_ban[0], 10) : 10));
|
||||||
while ( user_history.length > 20 )
|
ban_history[user] = [duration, reason, now];
|
||||||
user_history.shift();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// Show a Notice
|
||||||
|
var message = (is_me ? 'You have' : FFZ.get_capitalization(user) + ' has') + ' been ' + (duration === undefined ? 'timed out' : duration === true ? 'banned' : 'timed out for ' + utils.number_commas(duration) + utils.pluralize(' second'));
|
||||||
|
if ( ! identical_ban && ! disable_log && (is_me || this.ffzShouldDisplayNotice()) )
|
||||||
|
this.addTmiMessage(message + (reason ? ' with reason: ' + reason : '.'));
|
||||||
|
|
||||||
|
|
||||||
|
// Mod Card History
|
||||||
|
if ( room && f.settings.mod_card_history && ! disable_log ) {
|
||||||
|
var chat_history = room.user_history = room.user_history || {},
|
||||||
|
user_history = room.user_history[user] = room.user_history[user] || [],
|
||||||
|
|
||||||
|
has_delete = false,
|
||||||
|
last = user_history.length > 0 ? user_history[user_history.length-1] : null;
|
||||||
|
|
||||||
|
has_delete = last !== null && last.is_delete;
|
||||||
|
if ( has_delete && (identical_ban || (! last.has_reason && ! reason)) ) {
|
||||||
|
last.cachedTokens = [message + ' ' + utils.number_commas(++last.deleted_times) + ' times' + (reason ? ' with reason: ' + utils.sanitize(reason) : '.')];
|
||||||
|
} else {
|
||||||
|
user_history.push({from: 'jtv', is_delete: true, style: 'admin', cachedTokens: [message + (reason ? ' with reason: ' + utils.sanitize(reason) : '.')], has_reason: reason !== undefined, deleted_times: 1, date: new Date()});
|
||||||
|
while ( user_history.length > 20 )
|
||||||
|
user_history.shift();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( f.settings.prevent_clear )
|
if ( f.settings.prevent_clear )
|
||||||
this.addTmiMessage("A moderator's attempt to clear chat was ignored.");
|
this.addTmiMessage("A moderator's attempt to clear chat was ignored.");
|
||||||
|
@ -1133,6 +1200,20 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ffzShouldDisplayNotice: function() {
|
||||||
|
return f.settings.timeout_notices === 2 || (f.settings.timeout_notices === 1 && this.get('isModeratorOrHigher'));
|
||||||
|
},
|
||||||
|
|
||||||
|
addNotification: function(msg) {
|
||||||
|
if ( msg ) {
|
||||||
|
// We don't want to display these notices because we're injecting our own messages.
|
||||||
|
if ( (msg.msgId === 'timeout_success' || msg.msgId === 'ban_success') && this.ffzShouldDisplayNotice() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
return this._super(msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
addMessage: function(msg) {
|
addMessage: function(msg) {
|
||||||
if ( msg ) {
|
if ( msg ) {
|
||||||
var is_whisper = msg.style === 'whisper';
|
var is_whisper = msg.style === 'whisper';
|
||||||
|
@ -1201,6 +1282,13 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the last ban for that user.
|
||||||
|
var f_room = f.rooms && f.rooms[msg.room],
|
||||||
|
ban_history = f_room && f_room.ban_history;
|
||||||
|
|
||||||
|
if ( ban_history && msg.from )
|
||||||
|
ban_history[msg.from] = false;
|
||||||
|
|
||||||
// Check for message from us.
|
// Check for message from us.
|
||||||
if ( ! is_whisper ) {
|
if ( ! is_whisper ) {
|
||||||
var user = f.get_user();
|
var user = f.get_user();
|
||||||
|
@ -1355,15 +1443,45 @@ FFZ.prototype._modify_room = function(room) {
|
||||||
|
|
||||||
|
|
||||||
ffzPatchTMI: function() {
|
ffzPatchTMI: function() {
|
||||||
|
var tmi = this.get('tmiRoom'),
|
||||||
|
room = this;
|
||||||
|
|
||||||
|
// Re-bind clearChat
|
||||||
|
Ember.run.next(function(){
|
||||||
|
tmi = room.get('tmiRoom');
|
||||||
|
if ( ! tmi || room.get('ffz_clearchat_patch') )
|
||||||
|
return;
|
||||||
|
|
||||||
|
var func = function(user, tags) { room.clearMessages(user, tags) };
|
||||||
|
if ( room && room._callbacks ) {
|
||||||
|
for(var i=0; i < room._callbacks.length; i++) {
|
||||||
|
var cb = room._callbacks[i];
|
||||||
|
if ( cb && cb.eventName === "clearchat" ) {
|
||||||
|
room._callbacks.splice(i, 1);
|
||||||
|
tmi.off("clearchat", cb.callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
room._callbacks.push({
|
||||||
|
emitter: tmi,
|
||||||
|
eventName: "clearchat",
|
||||||
|
callback: func
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
f.log("Room Not Fully Initialized -- Expect Double Timeouts", room);
|
||||||
|
tmi.off("clearchat");
|
||||||
|
}
|
||||||
|
|
||||||
|
tmi.on("clearchat", func);
|
||||||
|
room.set('ffz_clearchat_patch', true);
|
||||||
|
});
|
||||||
|
|
||||||
if ( this.get('ffz_is_patched') || ! this.get('tmiRoom') )
|
if ( this.get('ffz_is_patched') || ! this.get('tmiRoom') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( f.settings.chatter_count )
|
if ( f.settings.chatter_count )
|
||||||
this.ffzInitChatterCount();
|
this.ffzInitChatterCount();
|
||||||
|
|
||||||
var tmi = this.get('tmiRoom'),
|
|
||||||
room = this;
|
|
||||||
|
|
||||||
// Let's get chatter information!
|
// Let's get chatter information!
|
||||||
// TODO: Remove this cause it's terrible.
|
// TODO: Remove this cause it's terrible.
|
||||||
var connection = tmi._roomConn._connection;
|
var connection = tmi._roomConn._connection;
|
||||||
|
|
|
@ -37,7 +37,7 @@ FFZ.msg_commands = {};
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
var VER = FFZ.version_info = {
|
var VER = FFZ.version_info = {
|
||||||
major: 3, minor: 5, revision: 174,
|
major: 3, minor: 5, revision: 176,
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
||||||
}
|
}
|
||||||
|
@ -112,8 +112,8 @@ FFZ.prototype._pastebin = function(data, callback) {
|
||||||
// User Data
|
// User Data
|
||||||
// -------------------
|
// -------------------
|
||||||
|
|
||||||
FFZ.prototype.get_user = function() {
|
FFZ.prototype.get_user = function(force_reload) {
|
||||||
if ( this.__user )
|
if ( ! force_reload && this.__user )
|
||||||
return this.__user;
|
return this.__user;
|
||||||
|
|
||||||
var LC = FFZ.utils.ember_lookup('controller:login'),
|
var LC = FFZ.utils.ember_lookup('controller:login'),
|
||||||
|
|
|
@ -2078,6 +2078,11 @@ body:not([data-current-path^="user."]) .ffz-sidebar-swap .ember-chat .chat-inter
|
||||||
|
|
||||||
/* No Blue */
|
/* No Blue */
|
||||||
|
|
||||||
|
.ffz-no-blue .theatre .ember-chat .chat-interface .textarea-contain textarea {
|
||||||
|
background-color: rgba(255,255,255,0.05);
|
||||||
|
border-color: rgba(255,255,255,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
.ffz-no-blue #carousel .nav {
|
.ffz-no-blue #carousel .nav {
|
||||||
background-color: rgba(25,25,25,.5);
|
background-color: rgba(25,25,25,.5);
|
||||||
}
|
}
|
||||||
|
@ -2403,6 +2408,7 @@ li[data-name="following"] a {
|
||||||
|
|
||||||
.ffz-directory-logo .meta p.title {
|
.ffz-directory-logo .meta p.title {
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
|
min-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ffz-directory-logo .meta p { width: auto; }
|
.ffz-directory-logo .meta p { width: auto; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue