summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2023-10-14 09:28:35 -0400
committerSacha Chua <sacha@sachachua.com>2023-10-14 09:28:35 -0400
commit03411976386867a223657d1a19f2afe991160d3a (patch)
tree9bb99b5d3469d0e466d610848b84e8979ef37241
parent97f033b4a2ab1be27c814e7aa85b34596a7720ad (diff)
downloademacsconf-el-03411976386867a223657d1a19f2afe991160d3a.tar.xz
emacsconf-el-03411976386867a223657d1a19f2afe991160d3a.zip
add emacsconf-spookfox
-rw-r--r--emacsconf-spookfox.el72
1 files changed, 72 insertions, 0 deletions
diff --git a/emacsconf-spookfox.el b/emacsconf-spookfox.el
new file mode 100644
index 0000000..a120e84
--- /dev/null
+++ b/emacsconf-spookfox.el
@@ -0,0 +1,72 @@
+;;; emacsconf-spookfox.el --- Spookfox browser automation -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023 Sacha Chua
+
+;; Author: Sacha Chua <sacha@sachachua.com>
+;; Keywords: convenience
+
+;; 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 of the License, 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.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(defun emacsconf-spookfox-create-bbb (group)
+ "Create a BBB room for this group of talks.
+GROUP is (email . (talk talk talk)).
+Needs a Spookfox connection."
+ (let* ((bbb-name
+ (format "%s (%s) - %s%s"
+ (mapconcat (lambda (o) (plist-get o :slug)) (cdr group) ", ")
+ (plist-get (cadr group) :speakers)
+ emacsconf-id
+ emacsconf-year))
+ path
+ (retrieve-command
+ (format
+ "window.location.origin + [...document.querySelectorAll('h4.room-name-text')].find((o) => o.textContent.trim() == '%s').closest('tr').querySelector('.delete-room').getAttribute('data-path')"
+ bbb-name))
+ (create-command (format "document.querySelector('#create-room-block').click();
+document.querySelector('#create-room-name').value = \"%s\";
+document.querySelector('#room_mute_on_join').click();
+document.querySelector('.create-room-button').click();"
+ bbb-name)))
+ (setq path (spookfox-js-injection-eval-in-active-tab retrieve-command t))
+ (unless path
+ (dolist (cmd (split-string create-command ";"))
+ (spookfox-js-injection-eval-in-active-tab cmd t)
+ (sleep-for 2))
+ (sleep-for 2)
+ (setq path (spookfox-js-injection-eval-in-active-tab retrieve-command t)))
+ (when path
+ (dolist (talk (cdr group))
+ (save-window-excursion
+ (emacsconf-with-talk-heading talk
+ (org-entry-put (point) "ROOM" path))))
+ (cons bbb-name path))))
+
+(defun emacsconf-spookfox-create-bbb-for-live-talks ()
+ "Create BBB rooms for talks that don't have them yet."
+ (let* ((talks (seq-filter
+ (lambda (o)
+ (and (string-match "live" (or (plist-get o :q-and-a) ""))
+ (not (string= (plist-get o :status) "CANCELLED"))
+ (not (plist-get o :bbb-room))))
+ (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))))
+ (groups (and talks (emacsconf-mail-groups talks))))
+ (dolist (group groups)
+ (emacsconf-spookfox-create-bbb group))))
+
+(provide 'emacsconf-spookfox)
+;;; emacsconf-spookfox.el ends here