add link shortening via !shorten

master
opfez 2021-10-04 10:19:04 +00:00
parent af4763ca21
commit 12443a4819
1 changed files with 16 additions and 2 deletions

View File

@ -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")