|
19 | 19 | (defn caesar [k message] message
|
20 | 20 | (apply str (rotate k (seq (clojure.string/lower-case message)))))
|
21 | 21 |
|
22 |
| -(def plaintexts '("men generally believe what they want to believe" |
| 22 | +(def plaintexts '("i came i saw i conquered" |
| 23 | + "men generally believe what they want to believe" |
23 | 24 | "i came i saw i conquered"
|
24 |
| - "i like treason but not traitors")) |
| 25 | + "i like treason but not traitors" |
| 26 | + "experience is the teacher of all things" |
| 27 | + "no one is so brave that he is not disturbed by something unexpected" |
| 28 | + "cowards die many times before their actual deaths" |
| 29 | + "the valiant never taste of death but once" |
| 30 | + "arms and laws do not flourish together")) |
25 | 31 |
|
26 | 32 | (defn plaintext [x] (nth plaintexts (mod (atol x) (count plaintexts))))
|
27 | 33 |
|
28 | 34 | (defn ciphertext [x] (caesar (mod (atol x) 13) (plaintext x)))
|
29 | 35 |
|
30 |
| -(def success-text "Well done! That makes sense. It seems that Julias Caesar, the roman empire had a similar epiphany.") |
| 36 | +(def success-texts '("Well done! That makes sense. It seems that Julius Caesar, the roman empire had a similar epiphany." |
| 37 | + "Congratulations! That's one small step for man, one giant leap for mankind." |
| 38 | + "Amazing! Seems we have a kind of an expert here." |
| 39 | + "Awesome. As Julius Caesar said: the die is cast.")) |
31 | 40 |
|
32 | 41 | (def wrong-texts '("Doesn't match! Please try again!"
|
33 | 42 | "Sorry, that’s incorrect. Try again!"
|
|
54 | 63 | time-of-message (get-in payload [:timestamp])
|
55 | 64 | message-text (get-in payload [:message :text])]
|
56 | 65 | (cond
|
57 |
| - (s/includes? (s/lower-case message-text) (plaintext sender-id)) (fb/send-message sender-id (fb/text-message success-text)) |
| 66 | + (s/includes? (s/lower-case message-text) (plaintext sender-id)) (fb/send-message sender-id (fb/text-message (rand-nth success-texts))) |
58 | 67 | :else (fb/send-message sender-id (rand-wrong)))))
|
59 | 68 |
|
60 | 69 | (defn on-postback [payload]
|
|
76 | 85 | recipient-id (get-in payload [:recipient :id])
|
77 | 86 | time-of-message (get-in payload [:timestamp])
|
78 | 87 | attachments (get-in payload [:message :attachments])]
|
79 |
| - (fb/send-message sender-id (fb/text-message "Thanks for your attachments :)")))) |
| 88 | + (fb/send-message sender-id (fb/text-message (rand-nth '("Thanks, looks nice. :)" "Thanks, i like!")))))) |
0 commit comments