added ability to post polls
added function to convert time into seconds
This commit is contained in:
parent
48134e5fcd
commit
e2447d07ec
18
README.md
18
README.md
|
@ -117,12 +117,17 @@ if BODY is not provided drops into a loop where we sleep until the user quits us
|
|||
|
||||
---
|
||||
|
||||
`post (text &key (visibility :unlisted) cw media sensitive)`
|
||||
`post (text &key (visibility :unlisted) cw media sensitive
|
||||
poll-options poll-multiple-choice-p poll-timeout poll-hide-totals-p)`
|
||||
|
||||
a thin wrapper around TOOTER:MAKE-STATUS
|
||||
|
||||
will automatically generate a content warning if cw-mappings was provided when the bot was created
|
||||
|
||||
|
||||
Note: POLL-TIMEOUT is the number of seconds until the poll ends
|
||||
|
||||
|
||||
`(post "hi~" :visibility :public)`
|
||||
|
||||
|
||||
|
@ -229,6 +234,17 @@ if AT is nil, code is ran at midnight on DAY
|
|||
|
||||
---
|
||||
|
||||
`time-to-seconds &rest rest`
|
||||
|
||||
takes all values passed as REST, converts the time into seconds, and returns the total
|
||||
|
||||
REST should be arguments compatible with PARSE-TIME
|
||||
|
||||
|
||||
example usage: (time-to-seconds 1 :day 2 :hours 30 :minutes)
|
||||
|
||||
---
|
||||
|
||||
`add-command (cmd function &key privileged add-prefix)`
|
||||
|
||||
adds a command with CMD being the text to trigger the command and FUNCTION being the function that runs
|
||||
|
|
|
@ -91,17 +91,24 @@ if INCLUDE-MENTIONS is non-nil, include mentions besides the primary account bei
|
|||
:spoiler-text (or cw (tooter:spoiler-text status))
|
||||
:in-reply-to (tooter:id status))))
|
||||
|
||||
(defun post (text &key (visibility :unlisted) cw sensitive media)
|
||||
(defun post (text &key (visibility :unlisted) cw sensitive media
|
||||
poll-options poll-multiple-choice-p poll-timeout poll-hide-totals-p)
|
||||
"a thin wrapper around tooter:make-status
|
||||
will automatically generate a content warning if cw-mappings was provided when the bot was created
|
||||
|
||||
Note: POLL-TIMEOUT is the number of seconds until the poll ends
|
||||
|
||||
see documentation for that function"
|
||||
(tooter:make-status (bot-client *bot*)
|
||||
text
|
||||
:visibility visibility
|
||||
:spoiler-text (or cw (generate-cw text (config :cw-mappings)))
|
||||
:media (upload-media media)
|
||||
:sensitive sensitive))
|
||||
:sensitive sensitive
|
||||
:poll-options poll-options
|
||||
:poll-expire-seconds poll-timeout
|
||||
:poll-multiple poll-multiple-choice-p
|
||||
:poll-hide-totals poll-hide-totals-p))
|
||||
|
||||
;; strips out html-tags/bot-username if we have that set in our config
|
||||
(defmethod tooter:decode-entity :after ((status tooter:status) data)
|
||||
|
|
|
@ -33,4 +33,5 @@
|
|||
:fave-p
|
||||
:mention-p
|
||||
:delete-parent
|
||||
:bot-post-p))
|
||||
:bot-post-p
|
||||
:time-to-seconds))
|
||||
|
|
11
util.lisp
11
util.lisp
|
@ -43,7 +43,16 @@
|
|||
trigger-def nil)
|
||||
|
||||
:finally (return file-def))))
|
||||
|
||||
|
||||
(defun time-to-seconds (&rest rest)
|
||||
"takes all values passed as REST, converts the time into seconds, and returns the total
|
||||
|
||||
REST should be arguments compatible with PARSE-TIME
|
||||
example usage: (time-to-seconds 1 :day 2 :hours 30 :minutes)"
|
||||
(loop :for i :from 2 :to (length rest) :by 2
|
||||
:for time := (subseq rest (- i 2) i)
|
||||
|
||||
:summing (apply #'parse-time (car time) (cdr time))))
|
||||
|
||||
(defun parse-time (amount duration)
|
||||
"parses AMOUNT of DURATION into seconds"
|
||||
|
|
Loading…
Reference in New Issue