Skip to content

Instantly share code, notes, and snippets.

@devth
Created May 21, 2020 23:18
Show Gist options
  • Select an option

  • Save devth/bd154e76536eed783974764dc6e6a2d3 to your computer and use it in GitHub Desktop.

Select an option

Save devth/bd154e76536eed783974764dc6e6a2d3 to your computer and use it in GitHub Desktop.

Revisions

  1. devth created this gist May 21, 2020.
    16 changes: 16 additions & 0 deletions xkcd.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    (defn xkcd-cmd
    "xkcd # fetch current xkcd comic"
    {:yb/cat #{:fun :img}}
    [_]
    ((juxt :title :img :alt) (get-json endpoint)))

    (defn xkcd-idx-cmd
    "xkcd <index> # fetch xkcd number <index>"
    {:yb/cat #{:fun :img}}
    [{index :match}]
    ;; TODO fetch https://xkcd.com/<index>/info.0.json
    )

    (cmd-hook #"xkcd"
    #"\d+" xkcd-idx-cmd
    _ xkcd-cmd)