Skip to content

Commit

Permalink
Too many gifs are bad, mkay
Browse files Browse the repository at this point in the history
  • Loading branch information
night committed Dec 24, 2015
1 parent fd06c6d commit 3c53eda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion betterttv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,8 @@ var bttvEmoticonize = exports.bttvEmoticonize = function(message, emote, sender)
var bttvMessageTokenize = exports.bttvMessageTokenize = function(sender, message) {
var tokenizedString = message.split(' ');

var gifCount = 0;

for (var i = 0; i < tokenizedString.length; i++) {
var piece = tokenizedString[i];

Expand All @@ -2447,9 +2449,11 @@ var bttvMessageTokenize = exports.bttvMessageTokenize = function(sender, message
emote &&
emote.urlTemplate &&
bttv.settings.get('bttvEmotes') === true &&
(emote.imageType === 'png' || (emote.imageType === 'gif' && bttv.settings.get('bttvGIFEmotes') === true))
(emote.imageType === 'png' || (emote.imageType === 'gif' && bttv.settings.get('bttvGIFEmotes') === true)) &&
gifCount < 5
) {
piece = bttvEmoticonize(piece, emote, sender);
gifCount++;
} else {
piece = escape(piece);
piece = linkify(piece);
Expand Down
6 changes: 5 additions & 1 deletion src/chat/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ var bttvEmoticonize = exports.bttvEmoticonize = function(message, emote, sender)
var bttvMessageTokenize = exports.bttvMessageTokenize = function(sender, message) {
var tokenizedString = message.split(' ');

var gifCount = 0;

for (var i = 0; i < tokenizedString.length; i++) {
var piece = tokenizedString[i];

Expand All @@ -158,9 +160,11 @@ var bttvMessageTokenize = exports.bttvMessageTokenize = function(sender, message
emote &&
emote.urlTemplate &&
bttv.settings.get('bttvEmotes') === true &&
(emote.imageType === 'png' || (emote.imageType === 'gif' && bttv.settings.get('bttvGIFEmotes') === true))
(emote.imageType === 'png' || (emote.imageType === 'gif' && bttv.settings.get('bttvGIFEmotes') === true)) &&
gifCount < 5
) {
piece = bttvEmoticonize(piece, emote, sender);
gifCount++;
} else {
piece = escape(piece);
piece = linkify(piece);
Expand Down

0 comments on commit 3c53eda

Please sign in to comment.