   brainTrigger: (trigger) ->
     @brainTriggers().filter((t) -> t.name is trigger)?[0]
 
-  legacyTrigger: (trigger) ->
-    @brain.get "#{LEGACY_KEY}:#{trigger}"
-
   hardcodedTrigger: (trigger) ->
     phrase = HARDCODED_TRIGGERS[trigger]
     return unless phrase?
     name: trigger, phrase: phrase, author: 'Liona'
 
-  swapLegacy: (trigger) ->
-    legacyPhrase = @legacyTrigger(trigger)
-    if legacyPhrase?
-      @save(trigger, legacyPhrase)
-      @brain.remove "#{LEGACY_KEY}:#{trigger}"
-
 module.exports = TriggerRepository

hardcodedTriggers = require '../support/hardcoded_triggers'

class TriggerRepository
  LEGACY_KEY         = 'trigger'
  KEY                = 'triggers'
  HARDCODED_TRIGGERS = hardcodedTriggers


  constructor: (@brain) ->

  find: (trigger) ->
    @brainTrigger(trigger) || @hardcodedTrigger(trigger)

  save: (name, phrase, author = 'Liona') ->
    trigger = name: name, phrase: phrase, author: author
    triggers = @brainTriggers().filter (t) -> t.name isnt name
    triggers.push trigger

    @brain.set KEY, triggers
    trigger

  remove: (trigger) ->
    @brain.set KEY, @brainTriggers().filter (t) -> t.name isnt trigger

  all: ->
    all = (@hardcodedTrigger(trigger) for trigger, phrase of HARDCODED_TRIGGERS)
