在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):compufox/glacier开源软件地址(OpenSource Url):https://github.com/compufox/glacier开源编程语言(OpenSource Language):Common Lisp 100.0%开源软件介绍(OpenSource Introduction):ava foxlightweight wrapper for making mastodon bots Installationclone this repo into your local system definitions or Usagecreate a bot object, passing it (at minimum) a path to your config file then pass that bot object to 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 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. Examplesthe 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-bot :instance "mastodon.social" :access-token "n0tArealT0KEn"))
(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-bot :config-file "/path/to/bot.config" :on-notification #'maybe-respond))) the following runs a bot that will respond to posts with (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-bot :config-file "/path/to/bot.config"))) API
makes a bot and returns it. INSTANCE, ACCESS-TOKEN, STRIP-HTML, STRIP-USERNAME, TIMELINE are all options that are typically in a config file passing these values in allows the developer to skip specifying a config file and can pull values in from other places e.g., command line arguments CONFIG-FILE is a string or a path that denotes a glacier config file INSTANCE is a mastodon instance domain name, with or without http scheme ACCESS-TOKEN is an access token for a mastodon account on INSTANCE STRIP-HTML if non-nil incoming posts will have their html stripped from them. defaults to T STRIP-USERNAME if non-nil strips the bot's username from incoming posts. defaults to NIL TIMELINE string denoting which timeline should be used for the streaming websocket. can be one of 'user', 'public', 'direct'. defaults to 'user' ON-UPDATE a function that accepts a single mastodon status. gets ran for every new post that streams in from TIMELINE ON-DELETE a function that accepts a single status id. gets ran for every deleted status that streams in from TIMELINE ON-NOTIFICATION a function that accepts a single mastodon notification. gets ran for every notification that streams in from TIMELINE
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.
a thin wrapper around TOOTER:MAKE-STATUS
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
returns T if NOTIFICATION is a mention
returns T if NOTIFICATION is a favourite
returns T if NOTIFICATION is a boost
returns T if NOTIFICATION is from a poll ending
returns T if NOTIFICATION is a follow-request
returns T if NOTIFICATION is a follow
returns T if STATUS was posted by the bot
returns T if ACCOUNT (or account from MENTION) has #NoBot in their profile's bio
deletes the parent to STATUS if it was made by the bot
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"
same as AFTER except repeats after every duration if RUN-IMMEDIATELY is non-nil, executes BODY once before waiting for the next iteration
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
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
the string that prefixes commands. defaults to "!"
terminates the websocket connection that feeds the bot streaming updates effectively terminates the bot LicenseBSD 3-Clause |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论