Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add twitch-specific functionality #425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/parse_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ var replyFor = require('./codes');
module.exports = function parseMessage(line, stripColors) {
var message = {};
var match;

// twitch.tv-specific, twitch stuffs a bunch of useful information here
// need to do a client.send("CAP REQ", "twitch.tv/tags") first
if(line.charAt(0) == "@") {
var tagend = line.indexOf(" ");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables declarations for aliases should not be used, but if you REALLY NEED them aliases, you should declare the variable at function-start and not on a if-statement.

var tag = line.slice(1, tagend);
line = line.slice(tagend + 1);
var pairs = tag.split(';');
var tags = {};
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=', 2);
tags[pair[0]] = pair[1];
}
message.tags = tags;
}

if (stripColors) {
line = ircColors.stripColorsAndStyle(line);
Expand Down