Since I've started using Emacs' appointment notifications with orgmode, I've wished that I could get notifications via XMPP. I think it's the most sensible system to use; I have it running on both my desktop, my phone, and my laptop, and the whole issue of "figuring out which device to send this notification to" has already been evaluated and solved by the XMPP community long long ago (back when everyone called XMPP Jabber, even ;)).
I initially thought I'd use a SleekXMPP bot connected to emacs via D-Bus, but then I decided that maybe I would eventually want to add more commands to this that integrated more closely with emacs, so maybe I should use emacs lisp directly. I had heard of Jabber.el but thought that it was mainly aimed at users who want a client, and that writing a bot in it would end up cluttering up my emacs with extra UI stuff I don't want. Then I was pointed at Steersman.el, and that seemed like a cleanly written bot, so I decided to give it a shot.
I was running a newer version of JabberEl than the copy of Steersman's code I looked at, so it took a little bit to figure out how to adjust for the multi-account code, but once I did that the implementation happened fairly quickly. Here's the relevant code:
;; Copyright (C) 2010 Chris Lemmer-Webber ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. (require 'jabber) (load-file "~/.emacs.d/emacs-jabberbot-login.el") (defun botler->appt-message-me (min-to-app new-time appt-msg) "Message me about an upcoming appointment." (let ((message-body (format "Appointment %s: %s%s" (if (string-equal "0" min-to-app) "now" (format "in %s minute%s" min-to-app (if (string-equal "1" min-to-app) "" "s"))) new-time appt-msg))) (jabber-send-sexp (jabber-find-connection "firstname.lastname@example.org") `(message ((to . "email@example.com") (type . "normal")) (body () ,message-body))))) ; I don't care when people come online to my bot's roster. (setq jabber-alert-presence-hooks nil) (setq appt-display-format 'window) (setq appt-disp-window-function 'botler->appt-message-me) (setq appt-delete-window-function (lambda ()))
Adjust "firstname.lastname@example.org" with your bot's JID and "email@example.com" with who you want to send messages to. You can replace emacs-jabber-bot-login.el with whatevever you want to login with, but you probably want to setq jabber-account-list and then run (jabber-connect-all). Note that if you're connecting with a self-signed cert with Jabber.el you'll need to do:
(setq starttls-extra-arguments '("--insecure")) (setq starttls-use-gnutls t)
I haven't yet figured how to whitelist my own self-signed cert yet, and passing in --insecure makes me feel like a monster, but it works for now. Maybe it's about time I finally got my ssl cert signed for dustycloud.org.
Anyway! It works, and I've been successfully getting appointment messages from my emacs session over IM for the last week, and it's pretty great. Next up, configuring things so that I can retrieve my agenda over IM when I request it and be able to IM myself new tasks and events.