diff --git a/anna.scm b/anna.scm index 21eb73b..c4c6d0f 100755 --- a/anna.scm +++ b/anna.scm @@ -10,8 +10,8 @@ (ice-9 regex) (rnrs exceptions)) -(define +channels+ '("#tildetown" "#lisp" "#bots")) -;; (define +channels+ '("#bots")) +;; (define +channels+ '("#tildetown" "#lisp" "#bots" "#programming")) +(define +channels+ '("#bots")) (load "greets.scm") @@ -175,6 +175,18 @@ sublink))) (else "Symbol not found in documentation.")))) +(define (shorten-link link) + (if (null? link) + "Please provide a link to shorten." + (let* ((port (open-input-pipe (string-append "curl -F'shorten=" + (if (string-contains link "://") + link + (string-append "https://" link)) + "' https://ttm.sh"))) + (out (read-line port))) + (close-pipe port) + out))) + (define (greets category name) (if (not (assoc name category)) "0" @@ -315,6 +327,8 @@ (send-message stream chn (diceware (slist-ref data 4)))) ((equal? ":!qotd" command) (qotd stream chn)) + ((equal? ":!shorten" command) + (send-message stream chn (shorten-link (slist-ref data 4)))) ((and (= 7 (length data)) (equal? (list-tail data 4) '("ACTION" "shoots" "anna"))) (send-action stream chn "dies")