diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f401f86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +/target +/classes +/checkouts +profiles.clj +pom.xml +pom.xml.asc +*.jar +*.class +/.lein-* +/.nrepl-port +/.prepl-port +.hgignore +.hg/ + +# Development +_*.* + +# IDE +/.idea +worlds.iml diff --git a/README.md b/README.md new file mode 100644 index 0000000..15b211e --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# cloworlds +A Clojure library for interacting with Worlds. + + +Version + + +## Usage +https://clojars.org/org.clojars.fun/worlds + +## Documentation +To be implemented. + +### License +[GNU General Public License v3.0](./LICENSE) diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..fe26e72 --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to cloworlds + +TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..b1e3449 --- /dev/null +++ b/project.clj @@ -0,0 +1,8 @@ +(defproject org.clojars.fun/worlds "1.0.0" + :description "A Clojure library for interacting with Worlds." + :url "https://github.com/Whirlsplash/cloworlds" + :license {:name "GPLv3" + :url "https://www.gnu.org/licenses/gpl-3.0.en.html"} + :dependencies [[org.clojure/clojure "1.10.1"] + [http.async.client "1.3.1"]] + :repl-options {:init-ns worlds.core}) diff --git a/src/worlds/core.clj b/src/worlds/core.clj new file mode 100644 index 0000000..da7e575 --- /dev/null +++ b/src/worlds/core.clj @@ -0,0 +1,21 @@ +(ns worlds.core + (:require [http.async.client :as http])) + +(defn is-vip + "Check if a user currently has VIP status" + [username] + (with-open [client (http/create-client)] ; Spawn client and close at end of use + (let [response (http/GET client "http://www-dynamic.us.worlds.net/cgi-bin/vip.pl" :query {:Username username})] + (-> response + http/await ; Await response + http/string) ; Stringify response + (clojure.string/includes? response "You're already a VIP!")))) ; Check if VIP + +(defn get-info + "Get a user's information" + [username] + (with-open [client (http/create-client)] + (let [response (http/GET client "http://www-dynamic.us.worlds.net/cgi-bin/profile.pl" :query {:username username})] + (-> response + http/await + http/string)))) diff --git a/test/worlds/core_test.clj b/test/worlds/core_test.clj new file mode 100644 index 0000000..6d410ef --- /dev/null +++ b/test/worlds/core_test.clj @@ -0,0 +1,13 @@ +(ns worlds.core-test + (:require [clojure.test :refer :all] + [worlds.core :refer :all])) + +(deftest functions + (testing "is-vip" + ; Check if my I (fuwn) have VIP, this SHOULD return FALSE. + (is (= (is-vip "fuwn") false))) + (testing "get-info" + ; Check if the character count of my information is 351. This is generally + ; not a good way to test if this works but I rarely (or ever) change my + ; information so this should work. + (is (= (count (get-info "fuwn"))) 351)))