|
@@ -67,6 +67,7 @@
|
|
|
(:hourly (handle-cmd-weather chat-id id '("hourly")))
|
|
(:hourly (handle-cmd-weather chat-id id '("hourly")))
|
|
|
(:daily (handle-cmd-weather chat-id id '("daily")))
|
|
(:daily (handle-cmd-weather chat-id id '("daily")))
|
|
|
(:rates (handle-cmd-rates chat-id id args))
|
|
(:rates (handle-cmd-rates chat-id id args))
|
|
|
|
|
+ (:postcheckins (handle-cmd-post-checkins chat-id id args))
|
|
|
(otherwise (handle-admin-cmd chat-id text cmd args))))
|
|
(otherwise (handle-admin-cmd chat-id text cmd args))))
|
|
|
(send-dont-understand chat-id (preprocess-input text))))
|
|
(send-dont-understand chat-id (preprocess-input text))))
|
|
|
(when location
|
|
(when location
|
|
@@ -103,6 +104,8 @@
|
|
|
(otherwise (send-dont-understand chat-id (preprocess-input (subseq text 1)))))
|
|
(otherwise (send-dont-understand chat-id (preprocess-input (subseq text 1)))))
|
|
|
(send-dont-understand chat-id (preprocess-input (subseq text 1)))))
|
|
(send-dont-understand chat-id (preprocess-input (subseq text 1)))))
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+;; AKB
|
|
|
(defparameter +akb-vk-domain+ "baneks" "VK.com username of 'B-category anekdotes'")
|
|
(defparameter +akb-vk-domain+ "baneks" "VK.com username of 'B-category anekdotes'")
|
|
|
(defvar *akb-send-to* nil "List of chat-id's to send AKBs to")
|
|
(defvar *akb-send-to* nil "List of chat-id's to send AKBs to")
|
|
|
|
|
|
|
@@ -161,13 +164,14 @@
|
|
|
(log:error e)
|
|
(log:error e)
|
|
|
(telegram-send-message chat-id "Ошибочка вышла"))))
|
|
(telegram-send-message chat-id "Ошибочка вышла"))))
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+;; Finance
|
|
|
(defun handle-cmd-rates (chat-id message-id args)
|
|
(defun handle-cmd-rates (chat-id message-id args)
|
|
|
(log:info "handle-cmd-rates" chat-id message-id args)
|
|
(log:info "handle-cmd-rates" chat-id message-id args)
|
|
|
(let ((rates (get-rates)))
|
|
(let ((rates (get-rates)))
|
|
|
(telegram-send-message chat-id
|
|
(telegram-send-message chat-id
|
|
|
(format nil "Зеленый ~A, гейро ~A, британец ~A" (cdar rates) (cdadr rates) (cdaddr rates)))))
|
|
(format nil "Зеленый ~A, гейро ~A, британец ~A" (cdar rates) (cdadr rates) (cdaddr rates)))))
|
|
|
|
|
|
|
|
|
|
+;; Weather
|
|
|
(defun handle-cmd-weather (chat-id message-id args)
|
|
(defun handle-cmd-weather (chat-id message-id args)
|
|
|
(log:info "handle-cmd-weather" chat-id message-id args)
|
|
(log:info "handle-cmd-weather" chat-id message-id args)
|
|
|
(let ((location (cdr (assoc chat-id *chat-locations*))))
|
|
(let ((location (cdr (assoc chat-id *chat-locations*))))
|
|
@@ -183,7 +187,40 @@
|
|
|
(error (e)
|
|
(error (e)
|
|
|
(log:error e)
|
|
(log:error e)
|
|
|
"Ошибочка вышла"))
|
|
"Ошибочка вышла"))
|
|
|
- "Так а ты чьих будешь?"))))
|
|
|
|
|
|
|
+ "Так а ты чьих будешь?"))))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+;; Foursquare
|
|
|
|
|
+(defvar *fsq-send-to* (make-hash-table)
|
|
|
|
|
+ "Hash of chat-id's to fsq users list to send checkings to")
|
|
|
|
|
+
|
|
|
|
|
+(defun handle-cmd-post-checkins (chat-id message-id args)
|
|
|
|
|
+ (log:info "handle-cmd-post-checkins" chat-id message-id args)
|
|
|
|
|
+ (let ((users (gethash chat-id *fsq-send-to*)))
|
|
|
|
|
+ (if (null args)
|
|
|
|
|
+ (telegram-send-message chat-id
|
|
|
|
|
+ (if (null users)
|
|
|
|
|
+ "Пока никого не палим"
|
|
|
|
|
+ (format nil "Палим ~{~A~^, ~}" users)))
|
|
|
|
|
+ (progn
|
|
|
|
|
+ (dolist (user args)
|
|
|
|
|
+ (if (member user users :test #'equal)
|
|
|
|
|
+ (progn
|
|
|
|
|
+ (setf users (remove user users :test #'equal))
|
|
|
|
|
+ (telegram-send-message chat-id (format nil "Больше не палим ~A" user)))
|
|
|
|
|
+ (progn
|
|
|
|
|
+ (push user users)
|
|
|
|
|
+ (telegram-send-message chat-id (format nil "Теперь палим ~A" user)))))
|
|
|
|
|
+ (setf (gethash chat-id *fsq-send-to*) users)))))
|
|
|
|
|
+
|
|
|
|
|
+(defun process-latest-checkins ()
|
|
|
|
|
+ (handler-case
|
|
|
|
|
+ (dolist (checkin (fsq-fetch-new-checkins))
|
|
|
|
|
+ (let ((user (aget "id" (aget "user" checkin))))
|
|
|
|
|
+ (loop for chat-id being the hash-keys in *fsq-send-to* using (hash-value users)
|
|
|
|
|
+ do (when (member user users :test #'equal)
|
|
|
|
|
+ (telegram-send-message chat-id (fsq-format-checkin checkin))))))
|
|
|
|
|
+ (error (e) (log:error e))))
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun start ()
|
|
(defun start ()
|
|
@@ -200,6 +237,12 @@
|
|
|
(clon:make-typed-cron-schedule :minute '* :hour '*)
|
|
(clon:make-typed-cron-schedule :minute '* :hour '*)
|
|
|
:allow-now-p t)
|
|
:allow-now-p t)
|
|
|
:thread t)
|
|
:thread t)
|
|
|
|
|
+ (clon:schedule-function
|
|
|
|
|
+ (lambda () (process-latest-checkins))
|
|
|
|
|
+ (clon:make-scheduler
|
|
|
|
|
+ (clon:make-typed-cron-schedule :minute '* :hour '*)
|
|
|
|
|
+ :allow-now-p t)
|
|
|
|
|
+ :thread t)
|
|
|
(bordeaux-threads:make-thread
|
|
(bordeaux-threads:make-thread
|
|
|
(lambda ()
|
|
(lambda ()
|
|
|
(in-package #:chatikbot)
|
|
(in-package #:chatikbot)
|