             (log/error e "dictionary-status")
             "Can not access database")))
 
+(defn get-nick
+    [prefix input]
+    (-> input (subs (count prefix)) clojure.string/trim))
+
 (defn congrats?
     [input]
     (re-matches #"congrats [a-zA-Z0-9]+" input))
 
 (defn congratulate-to
-    [name]
+    [nick]
     (let [message (rand-nth @congrat-messages)]
-       (format message name)))
+       (format message nick)))
 
 (defn congratulate
     [input]
-    (let [name (second (re-matches #"congrats ([a-zA-Z0-9]+)" input))]
-        (congratulate-to name)))
+    (let [nick (get-nick "congrats" input)]
+        (congratulate-to nick)))
+
+(defn happy-birthday-to
+    [nick]
+    (let [message (rand-nth @happy-birthday-messages)]
+       (format message nick)))
+
+(defn happy-birthday
+    [input]
+    (let [nick (get-nick "happy birthday" input)]
+        (happy-birthday-to nick)))
+
+(defn happy-birthday?
+    [input]
+    (re-matches #"happy birthday [a-zA-Z0-9]+" input))
 
 (defn prepare-reply-text
     [incomming-message nick input-text]

                              (and number-cruncher? (is-factorial? input))            (print-factorial input)
                              (and s-expressions?   (is-s-expression? input))         (s-expression input)
                              (congrats? input)                                       (congratulate input)
                              (is-word-from-known-responses? input) (return-known-response input)
                              (is-word-from-dictionary? input) (return-words-from-dictionary input)
                              (one-word-like-this? input)      (return-word-like-this input)

     " " (rand-nth @adjectives)
     " " (rand-nth @nouns)))

(defn say-quote
    [quotes]
    (rand-nth @quotes))

(defn primefactors 
    ([n] 
        (primefactors n 2 '()))
