* [PATCH] abstractions for different cities
@ 2026-02-17 22:30 Preston Pan
2026-02-18 1:53 ` Andrei Șova
0 siblings, 1 reply; 2+ messages in thread
From: Preston Pan @ 2026-02-17 22:30 UTC (permalink / raw)
To: nullerbot; +Cc: andreisva2023, Preston Pan
---
src/main.lisp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main.lisp b/src/main.lisp
index d789921..fb74901 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -19,12 +19,13 @@
(defparameter +feed-room-id+ "!ShuXi5ohrPUtKHkrNO:matrix.nullring.xyz")
(defparameter +feed-cache-path+ #P"./nullbot_cache.sexp")
(defparameter +feed-sleep-minutes+ 1)
+(defparameter +weather-vancouver+ )
(defparameter +prefix+ "$")
-(defun get-temp
- (&aux
- (endpoint "https://api.weather.gc.ca/collections/swob-realtime/items?f=json&lang=en&url=CYVR&sortby=-date_tm-value&limit=1&properties=date_tm-value,air_temp,air_temp-uom,air_temp-qa")
+(defun get-temp (weather-station
+ &aux
+ (endpoint (format nil "https://api.weather.gc.ca/collections/swob-realtime/items?f=json&lang=en&url=C~A&sortby=-date_tm-value&limit=1&properties=date_tm-value,air_temp,air_temp-uom,air_temp-qa" weather-station))
(data (jzon:parse (dex:get endpoint))))
(hash-get (aref (gethash "features" data) 0) '("properties" "air_temp")))
@@ -41,7 +42,7 @@
((string= command "$help")
(mapi:sendmsg *bot* room-id "Unlike some other bots, I'm nice :3"))
((string= command "$weather")
- (mapi:sendmsg *bot* room-id (format nil "It's ~a degrees in Vancouver" (get-temp)))))))
+ (mapi:sendmsg *bot* room-id (format nil "It's ~a degrees in Vancouver~%It's ~a degrees in Victoria" (get-temp "YVR") (get-temp "YYJ")))))))
(defmethod mapi:on-event
((obj nullbot) event room-id
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] abstractions for different cities
2026-02-17 22:30 [PATCH] abstractions for different cities Preston Pan
@ 2026-02-18 1:53 ` Andrei Șova
0 siblings, 0 replies; 2+ messages in thread
From: Andrei Șova @ 2026-02-18 1:53 UTC (permalink / raw)
To: Preston Pan; +Cc: nullerbot
[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]
Preston Pan <ret2pop@nullring.xyz> writes:
> ---
> src/main.lisp | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/main.lisp b/src/main.lisp
> index d789921..fb74901 100644
> --- a/src/main.lisp
> +++ b/src/main.lisp
> @@ -19,12 +19,13 @@
> (defparameter +feed-room-id+ "!ShuXi5ohrPUtKHkrNO:matrix.nullring.xyz")
> (defparameter +feed-cache-path+ #P"./nullbot_cache.sexp")
> (defparameter +feed-sleep-minutes+ 1)
> +(defparameter +weather-vancouver+ )
These are supposed to be constants but defining them with
`defconstant` is annoying because the repl complains when they are
redefined. Usually in CL when a variable is wrapped with '+' signs
it means that it's supposed to be constant.
>
> (defparameter +prefix+ "$")
>
> -(defun get-temp
> - (&aux
> - (endpoint "https://api.weather.gc.ca/collections/swob-realtime/items?f=json&lang=en&url=CYVR&sortby=-date_tm-value&limit=1&properties=date_tm-value,air_temp,air_temp-uom,air_temp-qa")
> +(defun get-temp (weather-station
> + &aux
> + (endpoint (format nil "https://api.weather.gc.ca/collections/swob-realtime/items?f=json&lang=en&url=C~A&sortby=-date_tm-value&limit=1&properties=date_tm-value,air_temp,air_temp-uom,air_temp-qa" weather-station))
> (data (jzon:parse (dex:get endpoint))))
> (hash-get (aref (gethash "features" data) 0) '("properties" "air_temp")))
>
> @@ -41,7 +42,7 @@
> ((string= command "$help")
> (mapi:sendmsg *bot* room-id "Unlike some other bots, I'm nice :3"))
> ((string= command "$weather")
> - (mapi:sendmsg *bot* room-id (format nil "It's ~a degrees in Vancouver" (get-temp)))))))
> + (mapi:sendmsg *bot* room-id (format nil "It's ~a degrees in Vancouver~%It's ~a degrees in Victoria" (get-temp "YVR") (get-temp "YYJ")))))))
>
> (defmethod mapi:on-event
> ((obj nullbot) event room-id
Looks good to me though
- sova
[-- Attachment #2: Type: text/html, Size: 2844 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-18 1:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-17 22:30 [PATCH] abstractions for different cities Preston Pan
2026-02-18 1:53 ` Andrei Șova
Code repositories for project(s) associated with this public inbox
https://git.nullring.xyz/nullerbot.git
https://git.nullring.xyz/nullerbot.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox