2ch
Version:
A JavaScript library for comfortable 2ch watching.
43 lines (35 loc) • 1.16 kB
JavaScript
(function() {
var Message, moment;
moment = require('moment');
module.exports = Message = (function() {
function Message(rawString, number) {
var body, dateAndId, strs, _ref;
this.rawString = rawString;
this.number = number;
_ref = this.rawString.split('<>'), this.name = _ref[0], this.mail = _ref[1], dateAndId = _ref[2], body = _ref[3];
this.body = body.trim();
this._over1000 = false;
this._abone = false;
if (dateAndId === 'Over 1000 Thread') {
this.postedAt = moment();
this.tripId = '';
this._over1000 = true;
} else if (dateAndId === 'あぼーん') {
this.postedAt = moment();
this.tripId = '';
this._abone = true;
} else {
strs = dateAndId.split(' ');
this.postedAt = moment(strs.slice(0, 2).join(' '), 'YYYY/MM/DD HH:mm:ss');
this.tripId = strs[2].replace(/^ID:/, '');
}
}
Message.prototype.isOver1000Message = function() {
return this._over1000;
};
Message.prototype.isAboneMessage = function() {
return this._abone;
};
return Message;
})();
}).call(this);