add link shortening via !shorten
parent
af4763ca21
commit
12443a4819
18
anna.scm
18
anna.scm
|
@ -10,8 +10,8 @@
|
||||||
(ice-9 regex)
|
(ice-9 regex)
|
||||||
(rnrs exceptions))
|
(rnrs exceptions))
|
||||||
|
|
||||||
(define +channels+ '("#tildetown" "#lisp" "#bots"))
|
;; (define +channels+ '("#tildetown" "#lisp" "#bots" "#programming"))
|
||||||
;; (define +channels+ '("#bots"))
|
(define +channels+ '("#bots"))
|
||||||
|
|
||||||
(load "greets.scm")
|
(load "greets.scm")
|
||||||
|
|
||||||
|
@ -175,6 +175,18 @@
|
||||||
sublink)))
|
sublink)))
|
||||||
(else "Symbol not found in documentation."))))
|
(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)
|
(define (greets category name)
|
||||||
(if (not (assoc name category))
|
(if (not (assoc name category))
|
||||||
"0"
|
"0"
|
||||||
|
@ -315,6 +327,8 @@
|
||||||
(send-message stream chn (diceware (slist-ref data 4))))
|
(send-message stream chn (diceware (slist-ref data 4))))
|
||||||
((equal? ":!qotd" command)
|
((equal? ":!qotd" command)
|
||||||
(qotd stream chn))
|
(qotd stream chn))
|
||||||
|
((equal? ":!shorten" command)
|
||||||
|
(send-message stream chn (shorten-link (slist-ref data 4))))
|
||||||
((and (= 7 (length data))
|
((and (= 7 (length data))
|
||||||
(equal? (list-tail data 4) '("ACTION" "shoots" "anna")))
|
(equal? (list-tail data 4) '("ACTION" "shoots" "anna")))
|
||||||
(send-action stream chn "dies")
|
(send-action stream chn "dies")
|
||||||
|
|
Loading…
Reference in New Issue