mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-18 08:52:00 +00:00
BetterTTV Integration
This commit is contained in:
parent
cc71863800
commit
4e6942e2f3
11 changed files with 576 additions and 100 deletions
|
@ -14,8 +14,6 @@ FFZ.prototype.setup_line = function() {
|
|||
Line.reopen({
|
||||
tokenizedMessage: function() {
|
||||
// Add our own step to the tokenization procedure.
|
||||
var tokens = f._emoticonize(this, this._super());
|
||||
f.log("Chat Tokens", tokens);
|
||||
return f._emoticonize(this, this._super());
|
||||
|
||||
}.property("model.message", "isModeratorOrHigher", "controllers.emoticons.emoticons.[]")
|
||||
|
@ -30,16 +28,45 @@ FFZ.prototype.setup_line = function() {
|
|||
didInsertElement: function() {
|
||||
this._super();
|
||||
|
||||
var el = this.get('element');
|
||||
var el = this.get('element'),
|
||||
user = this.get('context.model.from');
|
||||
|
||||
el.setAttribute('data-room', this.get('context.parentController.content.id'));
|
||||
el.setAttribute('data-sender', this.get('context.model.from'));
|
||||
el.setAttribute('data-sender', user);
|
||||
|
||||
f.render_badge(this);
|
||||
f.capitalize(this, user);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ---------------------
|
||||
// Capitalization
|
||||
// ---------------------
|
||||
|
||||
FFZ.capitalization = {};
|
||||
|
||||
FFZ.prototype.capitalize = function(view, user) {
|
||||
if ( FFZ.capitalization[user] )
|
||||
return view.$('.from').text(FFZ.capitalization[user]);
|
||||
|
||||
var f = this;
|
||||
jQuery.getJSON("https://api.twitch.tv/kraken/channels/" + user + "?callback=?")
|
||||
.always(function(data) {
|
||||
if ( data.display_name == undefined )
|
||||
FFZ.capitalization[user] = user;
|
||||
else
|
||||
FFZ.capitalization[user] = data.display_name;
|
||||
|
||||
f.capitalize(view, user);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------
|
||||
// Emoticon Replacement
|
||||
// ---------------------
|
||||
|
@ -83,7 +110,7 @@ FFZ.prototype._emoticonize = function(controller, tokens) {
|
|||
// emoticon.
|
||||
_.each(emotes, function(emote) {
|
||||
//var eo = {isEmoticon:true, cls: emote.klass};
|
||||
var eo = {emoticonSrc: emote.url, altText: emote.name};
|
||||
var eo = {isEmoticon:true, cls: emote.klass, emoticonSrc: emote.url, altText: emote.name};
|
||||
|
||||
tokens = _.compact(_.flatten(_.map(tokens, function(token) {
|
||||
if ( _.isObject(token) )
|
||||
|
|
|
@ -54,8 +54,14 @@ FFZ.chat_commands = {};
|
|||
|
||||
FFZ.prototype.room_message = function(room, text) {
|
||||
var lines = text.split("\n");
|
||||
for(var i=0; i < lines.length; i++)
|
||||
room.room.addMessage({style: 'ffz admin', from: 'FFZ', message: lines[i]});
|
||||
if ( this.has_bttv ) {
|
||||
for(var i=0; i < lines.length; i++)
|
||||
BetterTTV.chat.handlers.onPrivmsg(room.id, {style: 'admin', date: new Date(), from: 'jtv', message: lines[i]});
|
||||
|
||||
} else {
|
||||
for(var i=0; i < lines.length; i++)
|
||||
room.room.addMessage({style: 'ffz admin', date: new Date(), from: 'FFZ', message: lines[i]});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,22 +198,6 @@ FFZ.prototype._load_room_json = function(room_id, callback, data) {
|
|||
}
|
||||
|
||||
|
||||
/*FFZ.ws_commands.sets_for_room = function(data) {
|
||||
var room = this.rooms[data.room];
|
||||
if ( ! room )
|
||||
return;
|
||||
|
||||
for(var i=0; i < data.sets.length; i++) {
|
||||
var set = data.sets[i];
|
||||
if ( room.sets.contains(set) )
|
||||
continue;
|
||||
|
||||
room.sets.push(set);
|
||||
this.load_set(set);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// --------------------
|
||||
// Ember Modifications
|
||||
// --------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue