first push
This commit is contained in:
commit
4bca65889d
|
@ -0,0 +1,2 @@
|
|||
/bin/
|
||||
.DS_Store
|
|
@ -0,0 +1,19 @@
|
|||
LISPS = ros sbcl clisp cmucl ccl
|
||||
CMDS = --eval "(ql:quickload :df-bug-bot)" --eval "(asdf:make :df-bug-bot)" --eval "(quit)"
|
||||
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
LISP := $(foreach lisp,$(LISPS), \
|
||||
$(shell where $(lisp)) \
|
||||
$(if $(.SHELLSTATUS),$(strip $(lisp)),))
|
||||
else
|
||||
LISP := $(foreach lisp,$(LISPS), \
|
||||
$(if $(findstring $(lisp),"$(shell which $(lisp) 2>/dev/null)"), $(strip $(lisp)),))
|
||||
endif
|
||||
|
||||
ifeq ($(LISP),)
|
||||
$(error "No lisps found")
|
||||
endif
|
||||
|
||||
all:
|
||||
$(LISP) $(CMDS)
|
|
@ -0,0 +1,13 @@
|
|||
# df-bug-bot
|
||||
### _ava fox_
|
||||
|
||||
a mastodon bot that posts bugs from the dwarf fortress bug tracker
|
||||
|
||||
downloads the full bug list exported as CSV and parses it to remove any resolved bugs.
|
||||
|
||||
hosted here: https://botsin.space/@dfbugs
|
||||
|
||||
## License
|
||||
|
||||
NPLv1+
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
;;;; df-bug-bot.asd
|
||||
|
||||
(asdf:defsystem #:df-bug-bot
|
||||
:description "mastodon bot that posts bugs from the dwarf fortress bug tracker"
|
||||
:author "ava fox"
|
||||
:license "NPLv1+"
|
||||
:version "0.0.1"
|
||||
:serial t
|
||||
:depends-on (#:glacier #:cl-csv #:with-user-abort)
|
||||
:components ((:file "package")
|
||||
(:file "df-bug-bot"))
|
||||
:entry-point "df-bug-bot:main"
|
||||
:build-operation "program-op"
|
||||
:build-pathname "bin/df-bug-bot")
|
|
@ -0,0 +1,54 @@
|
|||
;;;; df-bug-bot.lisp
|
||||
|
||||
(in-package #:df-bug-bot)
|
||||
|
||||
(defvar *csv-file* #P"df-bugs.csv")
|
||||
(defvar *parsed-csv* nil)
|
||||
|
||||
(defun parse-csv ()
|
||||
"removes all bugs that aren't currently open"
|
||||
(remove-if #'(lambda (record)
|
||||
(not (string= (nth 13 record) "open")))
|
||||
(cl-csv:read-csv *csv-file*)))
|
||||
|
||||
(defun refresh-csv-file ()
|
||||
"downloads the bug CSV file and writes it to *CSV-FILE*"
|
||||
(with-open-file (output *csv-file* :direction :output
|
||||
:if-exists :supersede
|
||||
:if-does-not-exist :create)
|
||||
(format output "~A~%" (drakma:http-request "https://dwarffortress.mantishub.io/csv_export.php")))
|
||||
(setf *parsed-csv* (parse-csv)))
|
||||
|
||||
(defun get-random-bug ()
|
||||
"gets a random bug from the list"
|
||||
(nth (random (length *parsed-csv*)) *parsed-csv*))
|
||||
|
||||
(defun generate-post ()
|
||||
"generates a post"
|
||||
(let ((bug (get-random-bug)))
|
||||
(format t "~A: ~A" (nth 0 bug) (nth 11 bug))))
|
||||
|
||||
(defun main ()
|
||||
"main binary entry point"
|
||||
|
||||
;; go ahead and download our CSV file
|
||||
(refresh-csv-file)
|
||||
|
||||
(handler-case
|
||||
(with-user-abort
|
||||
(run-bot ((make-instance 'mastodon-bot :config-file "config.file")
|
||||
:with-websocket nil)
|
||||
|
||||
;; after every 4 days (and 13 min) refresh the bug list
|
||||
;; this should hopefully not overlap with the posting,
|
||||
;; because that might mess things up
|
||||
(after-every (5773 :minutes :async t)
|
||||
(refresh-csv-file))
|
||||
|
||||
;; post a random bug every hour
|
||||
(after-every (1 :hour :run-immediately t)
|
||||
(post (generate-post)))))
|
||||
|
||||
(user-abort ()
|
||||
(uiop:quit))))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
;;;; package.lisp
|
||||
|
||||
(defpackage #:df-bug-bot
|
||||
(:use #:cl :glacier :with-user-abort)
|
||||
(:export :main))
|
||||
|
||||
(in-package :df-bug-bot)
|
||||
|
||||
|
Loading…
Reference in New Issue