     if not (domain && domain.match(/^(?:[A-Za-z0-9\-\.]+\.)?phate\.(?:io|cc|us|tw|org)$/i)?)
       safe_referer = strip_hyper_links(strip_irc_colors(referer))
       throw "REFERRAL_DENIED: #{safe_referer}"
+
+  loadBlacklist: =>
+    self = this
+    self.db.collection(self.dbConfigName).find(
+      name: 'blacklist'
+    ).sort(id: 1).toArray (err, items) ->
+      throw err if err
+      return if items.length == 0
+      self.blacklist = JSON.parse(items[0].text)
+      DEBUG('Load %d blacklist items from database.', Object.keys(self.blacklist).length)
+
+  saveBlacklist: =>
+    self = this
+    criteria =
+      name: 'blacklist'
+    data =
+      name: 'blacklist'
+      text: JSON.stringify(self.blacklist)
+    options =
+      upsert: true
+    self.db.collection(self.dbConfigName).update criteria, data, options, (err, count, status) ->
+      throw err if err
+      DEBUG('Save blacklist to database. Returned %s', status)
 
   blacklistCheck: (ip) =>
     self = this


    self.dbUser = process.env.OPENSHIFT_MONGODB_DB_USERNAME
    self.dbPass = process.env.OPENSHIFT_MONGODB_DB_PASSWORD
    self.dbName = 'nodedanmaku'
    self.emitter = new emitter()

  setupVariables: =>

        count: 1
    self.last_response_uid = uid

  ignoredWordsCheck: (text) =>
    self = this
    throw 'IGNORED' if text.indexOf("\u0000") != -1

  say: (text, address, attributes = {}, callback = false) =>
    self = this
    uid = get_ip_with_tripcode(address)
    timestamp = (new Date()).getTime()

    top = attributes.top || Math.random()
    color = attributes.color || '255,255,255,0.9'
    size = attributes.size || 1.0
    weight = attributes.weight || 'bold'
    speed = attributes.speed || 1.0

    item =
      id: self.last_record_id + 1
