Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defmethod handle-event "!create-bet"
  2.   [event-type {:keys [channel-id content]}]
  3.   (let [split-content (str/split content #" ")
  4.         pw (get split-content 1)
  5.         game-id (get split-content 2)
  6.         team1 (get split-content 3)
  7.         team2 (get split-content 4)
  8.         state @state]
  9.     (when (and (= 5 (count split-content))
  10.                (= (hash pw) (:password state)))
  11.       (a/go
  12.         (a/>! betting-status-chan
  13.               {:open? true
  14.                :game-id game-id
  15.                :team1 team1
  16.                :team2 team2})
  17.        (m/create-message! (:messaging state) (:default-announcement-channel state)
  18.                           :content (str "Bets are now open for game " game-id
  19.                                         "\n" team1 " vs " team2 "!"
  20.                                         "\ntype ```!bet 1 <amount>``` to bet on " team1
  21.                                         "\nand ```!bet 2 <amount>``` to bet on " team2
  22.                                         "\nYou have " (/ (:betting-time state) 1000) " seconds to make your bet!"))
  23.        (a/<! (a/timeout (:betting-time state)))
  24.        (a/>! betting-status-chan
  25.              {:open? false
  26.               :game-id game-id
  27.               :team1 team1
  28.               :team2 team2})
  29.        (m/create-message! (:messaging state) (:default-announcement-channel state)
  30.                           :content "Bets are now closed! Good luck!")))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement