Get echoes list working

This commit is contained in:
Denis Zheleztsov 2017-09-28 17:12:09 +03:00
parent 5934c82010
commit 65df0a90c9

27
idec.el
View File

@ -21,7 +21,7 @@
;;; Commentary: ;;; Commentary:
;; In active developent full featured IDEC client. ;; In active developent.
;; Fetched node must be support modern IDEC extensions like /list.txt, /x/c, etc. ;; Fetched node must be support modern IDEC extensions like /list.txt, /x/c, etc.
;;; Code: ;;; Code:
@ -33,6 +33,7 @@
"IDEC configuration." "IDEC configuration."
:group 'network) :group 'network)
;; Not used
(defcustom idec-nodes-list (defcustom idec-nodes-list
'("http://idec.spline-online.tk/" '("http://idec.spline-online.tk/"
"https://ii-net.tk/ii/ii-point.php?q=/") "https://ii-net.tk/ii/ii-point.php?q=/")
@ -64,6 +65,11 @@
:type 'list :type 'list
:group 'idec) :group 'idec)
(defcustom idec-mail-dir "~/.emacs.d/idec-mail"
"Directory to store mail."
:type 'string
:group 'idec)
(defgroup idec-accounts nil (defgroup idec-accounts nil
"IDEC accounts settings." "IDEC accounts settings."
:group 'idec :group 'idec
@ -101,18 +107,27 @@
(defun proccess-echo-list (raw-list) (defun proccess-echo-list (raw-list)
"Parse RAW-LIST from HTTP response." "Parse RAW-LIST from HTTP response."
(with-output-to-temp-buffer "*IDEC: list.txt*" (with-output-to-temp-buffer "*IDEC: list.txt*"
(print raw-list))) (dolist (line (split-string (decode-coding-string raw-list 'utf-8) "\n"))
(if (not (equal line ""))
(print (format "Echo: %s || Description: %s || Count: %s"
(nth 0 (split-string line ":"))
(nth 2 (split-string line ":"))
(nth 1 (split-string line ":")))))
)))
(defun idec-fetch-echo-list (nodeurl) (defun idec-fetch-echo-list (nodeurl)
"Fetch echoes list from remote NODEURL." "Fetch echoes list from remote NODEURL."
(url-retrieve nodeurl) (with-current-buffer
(switch-to-buffer (current-buffer))) (url-retrieve-synchronously nodeurl)
(goto-char (point-min))
(re-search-forward "^$")
(delete-region (point) (point-min))
(proccess-echo-list (buffer-string))))
(defun idec-load-echoes () (defun idec-load-echoes ()
"Load echoes list from node." "Load echoes list from node."
(interactive) (interactive)
(dolist (node idec-nodes-list) (idec-fetch-echo-list (concat idec-primary-node "list.txt")))
(idec-fetch-echo-list (concat node "list.txt"))))
;; END OF ECHOES FUNCTIONS ;; END OF ECHOES FUNCTIONS
;; ;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;