2019-01-09 22:11:05 +00:00
|
|
|
;;; IRCExtension --- Enables irc client on FG42
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(defvar irc-servers
|
|
|
|
'(("irc.freenode.net"
|
|
|
|
:port 6697
|
|
|
|
:encryption tls
|
|
|
|
:channels ("#5hit")))
|
|
|
|
"A list of servers and channels to connect to.")
|
|
|
|
|
|
|
|
(defvar irc-auth nil
|
|
|
|
"The irc authentication credentials.
|
|
|
|
This would overridethe default behaviour which is based onauth-sources.")
|
|
|
|
|
2019-01-10 17:26:41 +00:00
|
|
|
(defvar irc-nickname "fg42-user"
|
|
|
|
"The default nickname for irc. ")
|
|
|
|
|
2019-01-09 22:11:05 +00:00
|
|
|
(defun irc/extract-secrets-from-auth-source ()
|
|
|
|
"Extract the irc authenticate data from the auth-sources.
|
|
|
|
|
|
|
|
As an example for ~/.authinfo.gpg should contain:
|
|
|
|
|
|
|
|
machine freenode login <nickname> port nickserv password <password>
|
|
|
|
|
|
|
|
Also the auth-sources should be set correctly.
|
|
|
|
It returns nil if no password is available."
|
|
|
|
(let ((auth-list '()))
|
|
|
|
(dolist (p (auth-source-search :port '("nickserv")
|
|
|
|
:require '(:port :user :secret)))
|
|
|
|
(let ((secret (plist-get p :secret))
|
|
|
|
(method (intern (plist-get p :port))))
|
|
|
|
|
|
|
|
(add-to-list 'auth-list
|
|
|
|
(list (plist-get p :host)
|
|
|
|
method
|
|
|
|
(plist-get p :user)
|
|
|
|
(if (functionp secret)
|
|
|
|
(funcall secret)
|
|
|
|
secret)))))
|
|
|
|
auth-list))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun irc/setup ()
|
|
|
|
"Setup the rcirc library which distributes with Emacs."
|
|
|
|
(set (make-local-variable 'scroll-conservatively) 8192)
|
|
|
|
(setq gnutls-min-prime-bits 2048))
|
|
|
|
|
|
|
|
(defun irc/connect ()
|
|
|
|
"Connects to IRC."
|
|
|
|
(interactive)
|
|
|
|
(require 'rcirc)
|
|
|
|
(require 'rcirc-notify)
|
|
|
|
|
|
|
|
;; Turns off keychain integration
|
|
|
|
(setenv "GPG_AGENT_INFO" nil)
|
|
|
|
|
|
|
|
;; Turn on debugging if the global debuging was enabled
|
|
|
|
(setq rcirc-debug-flag debug-on-error)
|
2019-01-10 19:16:46 +00:00
|
|
|
(setq rcirc-server-alist irc-servers)
|
2019-01-09 22:11:05 +00:00
|
|
|
(setq rcirc-authinfo (or (irc/extract-secrets-from-auth-source)
|
|
|
|
irc-auth))
|
2019-01-10 17:26:41 +00:00
|
|
|
(setq rcirc-default-nick irc-nickname)
|
2019-01-09 22:11:05 +00:00
|
|
|
(rcirc-notify-add-hooks)
|
2019-01-10 19:03:56 +00:00
|
|
|
(rcirc-track-minor-mode 1)
|
2019-01-09 22:11:05 +00:00
|
|
|
(rcirc nil))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun extensions/irc-initialize ()
|
|
|
|
"Initialize the irc extention."
|
|
|
|
|
|
|
|
;; Keep input line at bottom.
|
|
|
|
(add-hook 'rcirc-mode-hook 'irc/setup)
|
|
|
|
|
|
|
|
(ability irc-spell-checking ()
|
|
|
|
(add-hook 'rcirc-mode-hook (lambda ()
|
|
|
|
(flyspell-mode 1)))))
|
|
|
|
;
|
|
|
|
|
|
|
|
(provide 'extensions/irc/init)
|
|
|
|
;;; init.el ends here
|