aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/sx-bot.el31
-rwxr-xr-xbot/sx-bot.sh20
2 files changed, 32 insertions, 19 deletions
diff --git a/bot/sx-bot.el b/bot/sx-bot.el
index b32a69c..1a8bceb 100644
--- a/bot/sx-bot.el
+++ b/bot/sx-bot.el
@@ -48,12 +48,11 @@ File is savedd in `sx-bot-out-dir'."
(with-temp-file file-name
(let* (print-length
(repr (prin1-to-string
- (sort (cdr data)
- #'string-lessp))))
+ (sort (cdr data) #'string-lessp))))
(insert repr "\n")
(goto-char (point-min))
(while (search-forward "\" \"" nil t)
- (replace-match "\"\n \"" nil t))))
+ (replace-match "\"\n\"" nil t))))
(message "Wrote %S" file-name)
file-name))
@@ -61,19 +60,27 @@ File is savedd in `sx-bot-out-dir'."
"Get a list of all tags of all sites and save to disk."
(make-directory sx-bot-out-dir t)
(let* ((url-show-status nil)
- (site-tokens (sx-site-get-api-tokens))
+ (site-tokens (mapcar (lambda (site) ;Fix bad sites
+ (pcase site
+ ("metamunitybuilding" "meta.communitybuilding")
+ ((or "gamification" "meta.gamification") nil)
+ (_ site)))
+ (sx-site-get-api-tokens)))
(number-of-sites (length site-tokens))
(current-site-number 0)
- (sx-request-all-items-delay 0.25))
+ (sx-request-remaining-api-requests-message-threshold 4000)
+ (sx-request-all-items-delay 0))
(mapcar
(lambda (site)
- (message "[%d/%d] Working on %S"
- (cl-incf current-site-number)
- number-of-sites
- site)
- (sx-bot-write-to-file
- (cons (concat site ".el")
- (sx-tag--get-all site))))
+ (when site
+ (message "[%d/%d] Working on %S"
+ (cl-incf current-site-number)
+ number-of-sites
+ site)
+ (with-demoted-errors (concat "Failed to get " site ": %S")
+ (sx-bot-write-to-file
+ (cons (concat site ".el")
+ (sx-tag--get-all site))))))
site-tokens)))
diff --git a/bot/sx-bot.sh b/bot/sx-bot.sh
index 22c7284..32f6123 100755
--- a/bot/sx-bot.sh
+++ b/bot/sx-bot.sh
@@ -1,6 +1,9 @@
-#!/usr/bin/bash
+#!/usr/bin/env bash
+
+[[ -z "$EMACS" ]] && EMACS="emacs";
DESTINATION_BRANCH=data
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
function notify-done {
local title
@@ -20,17 +23,20 @@ function notify-done {
}
function generate-tags {
- emacs -Q --batch \
- -L "./" -L "./bot/" -l sx-bot \
- -f sx-bot-fetch-and-write-tags
- ret = $?
+ $EMACS -Q --batch \
+ -L "./" -L "./bot/" -l sx-bot \
+ -f sx-bot-fetch-and-write-tags
+ ret=$?
notify-done
return ${ret}
}
-git branch ${DESTINATION_BRANCH} &&
+git checkout ${DESTINATION_BRANCH} &&
git pull &&
generate-tags &&
git stage data/ &&
git commit -m "Update tag data" &&
- echo 'Ready for "git push"'
+ git push &&
+ echo 'Bot finished.'
+
+git checkout ${CURRENT_BRANCH}