Created
April 10, 2019 13:07
-
-
Save carrotflakes/c12a1299dcdff22c75dfebf2e46271d3 to your computer and use it in GitHub Desktop.
echo bot on twitter in Common Lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :chirp) | |
(setf chirp:*oauth-api-key* "Put" | |
chirp:*oauth-api-secret* "your" | |
chirp:*oauth-access-token* "credencials" | |
chirp:*oauth-access-secret* "here!") | |
(print (chirp:account/verify-credentials)) | |
(defun status-text-without-mention (status) | |
(chirp:replace-entities status (list :user-mention (lambda (x) "")))) | |
(defun user= (user1 user2) | |
(eq (chirp-objects:id user1) (chirp-objects:id user2))) | |
(defun start () | |
(loop | |
with time = (local-time:now) | |
with last-id = nil | |
for mentions = (chirp:statuses/mentions-timeline :since-id last-id) | |
do (loop | |
for mention in mentions | |
when (local-time:timestamp<= time (chirp-objects:created-at mention)) | |
unless (user= (chirp:account/self) (chirp-objects:user mention)) | |
do (print mention) | |
(chirp:reply mention (status-text-without-mention mention))) | |
(when mentions | |
(setf last-id (apply #'max (mapcar #'chirp-objects:id mentions)))) | |
(sleep (* 60 (/ 15 75))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment