|
|
@@ -13,14 +13,23 @@
|
|
|
(defun process-updates ()
|
|
|
(loop for update in (telegram-get-updates :offset (and *telegram-last-update*
|
|
|
(1+ *telegram-last-update*))
|
|
|
- :timeout 60)
|
|
|
+ :timeout 300)
|
|
|
do (handle-message (aget "message" update))
|
|
|
do (setf *telegram-last-update*
|
|
|
(max (or *telegram-last-update* 0)
|
|
|
(aget "update_id" update)))))
|
|
|
|
|
|
-(defun send-dont-understand (chat-id &optional reply-id)
|
|
|
- (telegram-send-message chat-id "Ну хуууй знает" :reply-to reply-id))
|
|
|
+(defvar *responses*
|
|
|
+ '("И чё?" "Сам-то понял?" "Ну хуй знает" "Бля..." "В душе не ебу" "Мне похуй")
|
|
|
+ "Unknown command respond strings")
|
|
|
+
|
|
|
+(defun send-dont-understand (chat-id &optional text reply-id)
|
|
|
+ (telegram-send-message chat-id
|
|
|
+ (if (and text (zerop (random 5)))
|
|
|
+ (format nil "Сам ~A"
|
|
|
+ (replace-all text "@chatikbot" ""))
|
|
|
+ (nth (random (length *responses*)) *responses*))
|
|
|
+ :reply-to reply-id))
|
|
|
|
|
|
(defun handle-message (message)
|
|
|
(let ((id (aget "message_id" message))
|
|
|
@@ -38,10 +47,8 @@
|
|
|
(case cmd
|
|
|
(:akb (handle-cmd-akb chat-id id args))
|
|
|
(:lastakb (handle-cmd-last-akb chat-id id args))
|
|
|
- (otherwise (send-dont-understand chat-id id))))
|
|
|
- (telegram-send-message chat-id
|
|
|
- (format nil "Сам ~A"
|
|
|
- (replace-all text "@chatikbot" "")))))))
|
|
|
+ (otherwise (send-dont-understand chat-id text))))
|
|
|
+ (send-dont-understand chat-id text)))))
|
|
|
|
|
|
(defparameter +akb-user-id+ "3021296351" "Twitter user id of 'B-category anecdotes'")
|
|
|
(defvar *akb-max-count* 5 "Max number of tweets to return per run")
|
|
|
@@ -88,7 +95,7 @@
|
|
|
(defvar *cron-timers* nil)
|
|
|
|
|
|
(defun start ()
|
|
|
- (mapc #'sb-ext:unschedule-timer *cron-timers*)
|
|
|
+ (mapc #'sb-ext:unschedule-timer (trivial-timers:list-all-timers))
|
|
|
(setf *cron-timers*
|
|
|
(loop for (function schedule) in *crons*
|
|
|
do (log:info "Starting cron" function schedule)
|