Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the glacier Reference Manual, version 0.3, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 13:36:23 2020 GMT+0.
• Introduction | What glacier is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
lightweight wrapper for making mastodon bots
clone this repo into your local system definitions or ~/common-lisp
folder
create a bot object, passing it (at minimum) a path to your config file
then pass that bot object to (glacier:run-bot)
if you pass nothing else but the bot object, the framework will drop into a loop monitoring for updates and running the proper handlers from your bot (assuming you specified what handlers to run when creating your bot object)
you can pass code along with your bot to (glacier:run-bot)
and it will
run that code along with monitoring for streaming updates
NOTE: if you pass code that doesn't block forever, the bot will exit without doing anything
;; bad example
(glacier:run-bot (my-bot)
(format t "my bot is running!")) ;; this doesn't block, so we print this and exit
see below for good examples
most objects that get passed around are tooter objects, so it probably wouldnt hurt to get acquainted with that library.
the following runs a bot (using the instance and access token specified in the config) that posts "trans rights are human rights" every 30 minutes
please see the example config for option names
(glacier:run-bot ((make-instance 'glacier:mastodon-bot :config-file "/path/to/bot.config"))
(glacier:after-every (30 :minutes)
(glacier:post "trans rights are human rights" :visibility :public)))
the following runs a bot that responds to a mention with a cordial hello
(defun maybe-respond (notification)
"respond to a status from a mention NOTIFICATION"
(when (glacier:mention-p notification)
(glacier:reply (tooter:status notification) "hi! :3")))
(glacier:run-bot ((make-instance 'glacier:mastodon-bot :config-file "/path/to/bot.config"
:on-notification #'maybe-respond)))
the following runs a bot that will respond to posts with !hello
in
them with status personalized with their displayname
(defun cordial-reply (status)
(glacier:reply status (format nil "hi, ~a! :3"
(tooter:display-name (tooter:account status)))))
(glacier:add-command "hello" #'cordial-reply)
(glacier:run-bot ((make-instance 'glacier:mastodon-bot :config-file "/path/to/bot.config")))
run-bot ((bot &key delete-command (with-websocket t)) &body body)
runs BOT, setting up websocket handlers and starting the streaming connection before executing BODY
if DELETE-COMMAND is non-nil, automatically adds a delete command if WITH-WEBSOCKET is non-nil (default), automatically starts up a websocket listener for realtime updates
NOTE: DELETE-COMMAND is ignored if WITH-WEBSOCKET is nil
if BODY is not provided drops into a loop where we sleep until the user quits us, or our connection closes. this functionality does not happen if WITH-WEBSOCKET is nil.
post (text &key (visibility :unlisted) cw media sensitive)
a thin wrapper around TOOTER:MAKE-STATUS
(post "hi~" :visibility :public)
reply (status text &key include-mentions media)
replys to STATUS with TEXT
if include-mentions is non-nil then the reply will contain all mentions from the original status
NOTE: reply will always include an @ to the person it's replying to
mention-p (notification)
returns T if NOTIFICATION is a mention
fave-p (notification)
returns T if NOTIFICATION is a favourite
boost-p (notification)
returns T if NOTIFICATION is a boost
poll-ended-p (notification)
returns T if NOTIFICATION is from a poll ending
follow-request-p (notification)
returns T if NOTIFICATION is a follow-request
follow-p (notification)
returns T if NOTIFICATION is a follow
bot-post-p (status)
returns T if STATUS was posted by the bot
no-bot-p (account-or-mention)
returns T if ACCOUNT (or account from MENTION) has #NoBot in their profile's bio
delete-parent (status)
deletes the parent to STATUS if it was made by the bot
after ((amount duration &key async) &body body)
runs BODY after AMOUNT of DURATION time has passed
if ASYNC is non-nil runs asynchronously
(after (3 :minutes) (print "hello"))
;; (after 3 minutes)
;;=> "hello"
after-every ((amount duration &key async run-immediately) &body body)
same as AFTER except repeats after every duration
if RUN-IMMEDIATELY is non-nil, executes BODY once before waiting for the next iteration
on ((day &key at async) &body body
runs BODY on DAY, optionally AT a time
DAY is a keyword with the day of the week (e.g., :sunday, :monday, etc)
AT is a string denoting a time (e.g., "13:20", "4:20PM", "23:00")
if ASYNC is non-nil code is executed asynchronously
if AT is nil, code is ran at midnight on DAY
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
FUNCTION needs to accept one parameter: a tooter:status object
if PRIVILEGED is non-nil, the bot needs to be following the account the mention comes from for the command to be triggered
if ADD-PREFIX is non-nil, adds *COMMAND-PREFIX* to the front of CMD
*command-prefix*
the string that prefixes commands.
defaults to "!"
terminate-connection
terminates the websocket connection that feeds the bot streaming updates
effectively terminates the bot
BSD 3-Clause
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The glacier system |
ava fox
BSD 3-Clause
lightweight mastodon bot framework
0.3
glacier.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The glacier.asd file | ||
• The glacier/package.lisp file | ||
• The glacier/bot.lisp file | ||
• The glacier/extensions.lisp file | ||
• The glacier/util.lisp file | ||
• The glacier/glacier.lisp file |
Next: The glacier/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
glacier.asd
glacier (system)
Next: The glacier/bot․lisp file, Previous: The glacier․asd file, Up: Lisp files [Contents][Index]
Next: The glacier/extensions․lisp file, Previous: The glacier/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
glacier (system)
bot.lisp
Next: The glacier/util․lisp file, Previous: The glacier/bot․lisp file, Up: Lisp files [Contents][Index]
bot.lisp (file)
glacier (system)
extensions.lisp
Next: The glacier/glacier․lisp file, Previous: The glacier/extensions․lisp file, Up: Lisp files [Contents][Index]
extensions.lisp (file)
glacier (system)
util.lisp
Previous: The glacier/util․lisp file, Up: Lisp files [Contents][Index]
util.lisp (file)
glacier (system)
glacier.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The glacier package |
package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
character or string that prefixes a command
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
runs BODY after AMOUNT of DURATION
if ASYNC is non-nil, runs asynchronously
runs BODY after every AMOUNT of DURATION
if ASYNC is non-nil, runs asynchronously
if RUN-IMMEDIATELY is non-nil, runs BODY once before waiting for next invocation
runs BODY on DAY, optionally AT a time
DAY is a keyword with the day of the week (e.g., :sunday, :monday, etc)
AT is a string denoting a time (e.g., ’13:20’, ’4:20PM’, ’23:00’)
if ASYNC is non-nil code is executed asynchronously
if AT is nil, code is ran at midnight on DAY
runs BOT, setting up websocket handlers and starting the streaming connection before executing BODY
if DELETE-COMMAND is non-nil, automatically adds a delete command
if WITH-WEBSOCKET is non-nil (default), automatically starts up a websocket listener for realtime updates
NOTE: DELETE-COMMAND is ignored used if WITH-WEBSOCKET is nil
if BODY is not provided drops into a loop where we sleep until the user quits us, or our connection closes. this functionality does not happen if WITH-WEBSOCKET is nil.
glacier.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
adds a command into our hash
CMD should be a string
FUNCTION should be a function that accepts a single parameter (a tooter:status object)
if PRIVILEGED is non-nil, command will only be triggered if mention is sent by an account the bot is following if ADD-PREFIX is non-nil, adds *COMMAND-PREFIX* to the front of CMD (defaults to t)
getf but for alists
checks if NOTIFICATION is a boost
checks if STATUS was posted by the bot
deletes the parent post of STATUS if it was posted by the bot
checks if NOTIFICATION is a favourite
checks if NOTIFICATION is a follow
checks if NOTIFICATION is a follow request
checks if NOTIFICATION is a mention
checks if NOTIFICATION is a poll
a thin wrapper around tooter:make-status
see documentation for that function
extensions.lisp (file)
closes the websocket connection and clears the variable from memory
glacier.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
checks account found in MENTION to see if they have NoBot set
extensions.lisp (file)
checks an account’s bio and profile fields to see if they contain a NoBot tag
extensions.lisp (file)
checks an account’s bio and profile fields to see if they contain a NoBot tag
extensions.lisp (file)
replies to a STATUS with TEXT. copies the visibility and content warning as the post it’s replying to
if INCLUDE-MENTIONS is non-nil, include mentions besides the primary account being replied to
extensions.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
bot superclass
bot.lisp (file)
standard-object (class)
:on-update
bot-on-update (generic function)
(setf bot-on-update) (generic function)
:on-delete
bot-on-delete (generic function)
(setf bot-on-delete) (generic function)
:on-notification
bot-on-notification (generic function)
(setf bot-on-notification) (generic function)
bot-account-id (generic function)
bot-username (generic function)
bot-client (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions | ||
• Internal generic functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
hash table containing the bot’s commands
KEY is the command as a string
VALUE is a function that accepts a tooter:status object as a parameter
regex to check for the NoBot tag
extensions.lisp (file)
hash table containing commands that will only be ran if the mention
is from an account the bot follows
KEY is the command as a string
VALUE is a function that accepts a tooter:status object as a parameter
global websocket client
glacier.lisp (file)
Next: Internal generic functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
adds https scheme to DOMAIN if it isnt already there
perform an API request
FRAGMENT is the fragment of the url that goes AFTER api/v1/
RESULT-TYPE (if provided) is the object type that we should use when parsing the response
can be either a symbol (’account) or list ’(:list account)
if it is a list then we decode the response and collect and return them as a list
extensions.lisp (file)
parses STATUS content for a command word, and runs any function it has in *commands* with it as the argument
if STATUS comes from an account the bot is following, also checks for any command in *privileged-commands*
glacier.lisp (file)
returns the current day of the week
gets the type of MESSAGE we received and calls the appropriate functions on our bot with the proper tooter object
glacier.lisp (file)
gets the websocket url for the mastodon instance
parses AMOUNT of DURATION into seconds
prints a message when the websocket is closed
prints a message when the websocket is connected
returns T if STATUS is from an account that the bot follows
determines how many seconds until HOURS MINUTES and SECONDS
if the time has already passed it returns 0 instead of a negative time
returns how many seconds until it’s midnight
parses TIME-STRING and returns how long until the time specified TIME-STRING is of the form ’12:04’, ’18:30’, ’1:10PM’, etc
Previous: Internal functions, Up: Internal definitions [Contents][Index]
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F G L |
---|
Jump to: | F G L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
A B C D F G M N O P R S T |
---|
Jump to: | (
A B C D F G M N O P R S T |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
A C O S |
---|
Jump to: | *
A C O S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | B C G M P S |
---|
Jump to: | B C G M P S |
---|