erc.el 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ;; Timestamps
  2. (setq erc-insert-away-timestamp-function #'erc-insert-timestamp-left)
  3. (setq erc-hide-timestamps nil)
  4. (setq erc-timestamp-only-if-changed-flag nil)
  5. (setq erc-accidental-paste-threshold-seconds 0.5)
  6. (setq erc-autojoin-mode t)
  7. (setq erc-autojoin-timing (quote ident))
  8. (setq erc-email-userid user-mail-address)
  9. (setq erc-flood-protect t)
  10. (setq erc-join-buffer (quote bury))
  11. (setq erc-query-display 'bury)
  12. (setq erc-auto-query 'bury)
  13. (setq erc-kill-buffer-on-part nil)
  14. (setq erc-kill-server-buffer-on-quit nil)
  15. (setq erc-networks-alist nil)
  16. (setq erc-nick-uniquifier nil)
  17. (setq erc-server-auto-reconnect t)
  18. (setq erc-server-reconnect-attempts t)
  19. (setq erc-server-reconnect-timeout 60)
  20. (setq erc-track-position-in-mode-line (quote t))
  21. (setq erc-track-priority-faces-only (quote all))
  22. (setq erc-track-switch-direction (quote importantce))
  23. (setq erc-try-new-nick-p nil)
  24. (setq erc-user-full-name "Oleg Pykhalov")
  25. (setq erc-whowas-on-nosuchnick t)
  26. (setq erc-track-exclude-types
  27. '("JOIN" "QUIT" "PART" "NICK" "333" "353"))
  28. (setq erc-hide-list '("JOIN" "PART" "QUIT"))
  29. (setq erc-modules
  30. '(autojoin button completion fill irccontrols list match menu notifications
  31. move-to-prompt netsplit networks ring smiley stamp track))
  32. (setq erc-fill-function 'erc-fill-variable)
  33. (setq erc-fill-prefix " ")
  34. (setq erc-fill-column 80)
  35. (defun wi-erc-connect-localhost ()
  36. "Connect to localhost irc network."
  37. (interactive)
  38. (erc :server "localhost"
  39. :port 6667
  40. :nick "natsu"
  41. :password nil))
  42. (defun wi-erc-connect-twitch ()
  43. "Connect to twitch irc network."
  44. (interactive)
  45. (add-to-list 'erc-networks-alist '(twitch "irc.chat.twitch.tv"))
  46. (erc-tls :server "irc.chat.twitch.tv"
  47. :port 6697
  48. :nick "wigust"
  49. :password nil))
  50. (defun wi-erc-connect-globalgamers ()
  51. "Connect to globalgamers irc network."
  52. (interactive)
  53. (add-to-list 'erc-networks-alist
  54. '(globalgamers "irc.globalgamers.net"))
  55. (erc-tls :server "irc.globalgamers.net"
  56. :port 6660
  57. :nick "wigust"
  58. :password nil))
  59. (defun wi-erc-connect-indymedia ()
  60. "Connect to indymedia irc network."
  61. (interactive)
  62. (add-to-list 'erc-networks-alist '(indymedia "irc.indymedia.org"))
  63. (erc-tls :server "irc.indymedia.org"
  64. :port 6697
  65. :nick "wigust"
  66. :password nil))
  67. (defun wi-erc-connect-gitter ()
  68. "Connect to gitter irc network."
  69. (interactive)
  70. (add-to-list 'erc-networks-alist '(gitter "irc.gitter.im"))
  71. (erc-tls :server "irc.gitter.im"
  72. :port 6697
  73. :nick "wigust"
  74. :password nil))
  75. (defun wi-erc-connect-gnome ()
  76. "Connect to gnome irc network."
  77. (interactive)
  78. (erc-tls :server "irc.gnome.org"
  79. :port 6697
  80. :nick "wigust"))
  81. (defun wi-erc-connect-freenode ()
  82. "Connect to freenode irc network."
  83. (interactive)
  84. (erc-tls :server "irc.freenode.net"
  85. :port 6697
  86. :nick "wigust"
  87. :password nil))
  88. (defun wi-erc-connect-debian ()
  89. "Connect to debian irc network."
  90. (interactive)
  91. (erc-tls :server "irc.oftc.net"
  92. :port 6697
  93. :nick "wigust"))
  94. (defun wi-erc-connect-rizon ()
  95. "Connect to highway irc network."
  96. (interactive)
  97. (erc-tls :server "irc.rizon.net"
  98. :port 6697
  99. :nick "wigust"))
  100. (defun wi-erc-connect-highway ()
  101. "Connect to highway irc network."
  102. (interactive)
  103. (erc-tls :server "irc.irchighway.net"
  104. :port 6697
  105. :nick "wigust"))
  106. (defun wi-erc-connect-all ()
  107. "Connect to all configured irc networks."
  108. (interactive)
  109. (wi-erc-connect-localhost) (wi-erc-connect-debian)
  110. (wi-erc-connect-freenode) (wi-erc-connect-gnome)
  111. (wi-erc-connect-gitter) (wi-erc-connect-twitch)
  112. (wi-erc-connect-rizon) (wi-erc-connect-globalgamers)
  113. ;; (wi-erc-connect-highway) ; No autojoin channels
  114. (wi-erc-connect-indymedia))
  115. (defvar wi-irc-gnome-servers '("umu.se" "gimp.net" "gimp.ca"
  116. "gnome.org" "y.se" "poop.nl"))
  117. (defvar wi-irc-gnome-channels
  118. '("#bugs" "#docs" "#gnome" "#gnome-hackers" "#gnome-shell"
  119. "#newcomers"))
  120. (defun wi-erc-netlist (irc-networks irc-channels)
  121. "A machinery to create list of IRC-NETWORKS and IRC-CHANNELS."
  122. (let (wi-erc-netlist)
  123. (dolist (irc-network irc-networks wi-erc-netlist)
  124. (if (equal wi-erc-netlist nil)
  125. (setq wi-erc-netlist
  126. (list (cons irc-network irc-channels)))
  127. (setq wi-erc-netlist
  128. (append wi-erc-netlist
  129. (list (cons irc-network irc-channels))))))))
  130. (defvar wi-erc-netlist-gnome (wi-erc-netlist wi-irc-gnome-servers
  131. wi-irc-gnome-channels))
  132. (setq erc-autojoin-channels-alist
  133. (quote
  134. (;; ("freenode.net"
  135. ;; ;; "#icecat" "#emacs" "#grub" "#conkeror" "#erc"
  136. ;; ;; "#clojure" "##math"
  137. ;; ;; "##c" "#gdb" "#bash" "#SDL" "#chicken"
  138. ;; ;; "#fedora" "#fedora-admin" "#fedora-devel"
  139. ;; ;; "#fedora-noc" "#fedora-meeting" "#fedora-qa"
  140. ;; ;; "#gnu" "#fsf" "#gnus"
  141. ;; "#guile" "#guix" "#lisp" "#scheme"
  142. ;; "#stumpwm" "#bootstrappable"
  143. ;; ;; "#replicant"
  144. ;; ;; "##linux" "#linuxdistrocommunity"
  145. ;; ;; "#nixos" "#haskell" "#xmonad"
  146. ;; ;; "#filmsbykris" "##japanese" "#latex"
  147. ;; ;; "#python" "#scipy" "#sagemath"
  148. ;; )
  149. ;; ("indymedia.org" "#riseup")
  150. ;; ("gitter.im")
  151. ;; ("oftc.net" "#debian" "#debian-next")
  152. ;; ("globalgamers" "#Touhou")
  153. ;; ("twitch.tv" "#tsoding" "#cattzs" "#retched"
  154. ;; "#bbsssssssss" "#team_treehouse" "#rw_grim")
  155. ;; ("uworld.se" "#coalgirls")
  156. )))
  157. (defun erc-netlist (wi-erc-netlist)
  158. (dolist (irc-net wi-erc-netlist)
  159. (append erc-autojoin-channels-alist irc-net)))
  160. (setq erc-autojoin-channels-alist
  161. (append erc-autojoin-channels-alist wi-erc-netlist-gnome))
  162. ;;;
  163. ;;; ZNC integration
  164. ;;;
  165. ;; Based on https://raw.githubusercontent.com/vincentbernat/dot.emacs/master/znc.conf.el
  166. (defun znc-setup (server port user networks)
  167. "Add a server to the list of ZNC servers.
  168. We use SSL inconditionaly. Moreover, we don't store the password
  169. but put nil instead. At least, we tweak the username to contain
  170. the network name later, this will be separated again."
  171. (setq znc-servers
  172. (list (list server port
  173. nil ;; SSL enabled
  174. (mapcar (function (lambda (slug)
  175. (list slug
  176. (format "%s/%s" user slug)
  177. nil)))
  178. networks)))))
  179. (defun vbe:znc-erc-connector (&rest R)
  180. "Connect to ERC using and retrieve password with `auth-source-search'.
  181. Moreover, handle multiple networks by sending the password with
  182. the appropriate network slug that we extract from the nick."
  183. (let* ((user (nth 0 (split-string (plist-get R :nick) "/")))
  184. (slug (nth 1 (split-string (plist-get R :nick) "/")))
  185. (port (plist-get R :port))
  186. (found (nth 0 (auth-source-search :host (plist-get R :server)
  187. :port port
  188. :user user
  189. :require '(:user :secret)
  190. :max 1))))
  191. (if found
  192. (let ((password (let ((secret (plist-get found :secret)))
  193. (if (functionp secret)
  194. (funcall secret)
  195. secret))))
  196. (plist-put R :password (format "%s/%s:%s" user slug password))
  197. (plist-put R :nick user)
  198. (apply 'erc R)))))
  199. (setq znc-erc-connector 'vbe:znc-erc-connector)
  200. ;; ;; Define networks
  201. (znc-setup "localhost" 8060 "wigust" '(freenode))