Skip to content

Commit

Permalink
clean up things
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearace committed Aug 18, 2014
1 parent 0e3f6f9 commit 064b8c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
13 changes: 6 additions & 7 deletions lib/cytubebot.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,10 @@ CytubeBot.prototype.checkUserBlacklist = function(username, callback) {
return

this.db.getUserBlacklist(username, function(flag) {
if (flag === "1") {
if (flag === "1")
callback(true)
} else {
else
callback(false)
}
})
};

Expand All @@ -453,11 +452,10 @@ CytubeBot.prototype.checkUserBlock = function(username, callback) {
return callback(false)

this.db.getUserBlock(username, function(flag) {
if (flag === "1") {
if (flag === "1")
callback(true)
} else {
else
callback(false)
}
})
};

Expand Down Expand Up @@ -663,6 +661,8 @@ CytubeBot.prototype.handleChatMsg = function(data, pm) {
var msg = data["msg"]
var time = data["time"]

this.logger.cytubelog.log("!~~~! Chat Message: " + username + ": " + msg)

// Ignore server messages
if (username === "[server]")
return
Expand All @@ -672,7 +672,6 @@ CytubeBot.prototype.handleChatMsg = function(data, pm) {
if (!msg)
return

this.logger.cytubelog.log("!~~~! Chat Message: " + username + ": " + msg)
if (this.useIRC && this.doneInit && msg.indexOf("(") !== 0 && !pm)
this.irc.sendMessage("(" + username + "): " + msg)

Expand Down
25 changes: 11 additions & 14 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ Database.prototype.getPopularVideos = function(callback) {
rows[i]["flags"], rows[i]["count"]
])
}

callback(returnData)
})
};
Expand All @@ -300,14 +299,12 @@ Database.prototype.getQuote = function(nick, callback) {
if (nick) {
stmt = this.db.prepare("SELECT username, msg, timestamp FROM chat WHERE " +
"username = ? COLLATE NOCASE ORDER BY RANDOM() LIMIT 1", [nick])

stmt.get(function(err, row) {
if (row) {
callback(row)
return
}
if (row)
return callback(row)
})
callback(0)
return
return callback(0)
}

stmt = "SELECT username, msg, timestamp FROM chat WHERE msg NOT LIKE '/me%' " +
Expand Down Expand Up @@ -391,11 +388,12 @@ Database.prototype.getVideos = function(num, callback) {
// Gets the number of videos in the database
// callback - The callback function
Database.prototype.getVideosCount = function(callback) {
var self = this

this.db.get("SELECT count(*) AS count FROM videos", function(err, row) {
if (err) {
this.logger.errlog.log(err)
return
}
if (err)
return self.logger.errlog.log(err)

callback(row["count"])
})
};
Expand Down Expand Up @@ -432,10 +430,9 @@ Database.prototype.getVideoFlag = function(type, id, callback) {
var stmt = this.db.prepare("SELECT flags FROM videos videos WHERE type = ? AND id = ?", [type, id])

stmt.get(function(err, row) {
if (row) {
if (row)
callback(row)
} else {
else
callback(0)
}
})
};

0 comments on commit 064b8c9

Please sign in to comment.