Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
major: Furnish
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Apr 10, 2021
1 parent 846b590 commit 1f41bcd
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# cloworlds
A Clojure library for interacting with Worlds.

<a href="https://clojars.org/org.clojars.fun/worlds">
<img src="https://img.shields.io/clojars/v/org.clojars.fun/worlds.svg" alt="Version" />
</a>

## Usage
https://clojars.org/org.clojars.fun/worlds

## Documentation
To be implemented.

### License
[GNU General Public License v3.0](./LICENSE)
3 changes: 3 additions & 0 deletions doc/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction to cloworlds

TODO: write [great documentation](http://jacobian.org/writing/what-to-write/)
8 changes: 8 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -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})
21 changes: 21 additions & 0 deletions src/worlds/core.clj
Original file line number Diff line number Diff line change
@@ -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))))
13 changes: 13 additions & 0 deletions test/worlds/core_test.clj
Original file line number Diff line number Diff line change
@@ -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)))

0 comments on commit 1f41bcd

Please sign in to comment.