-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-circe.el
312 lines (280 loc) · 10.5 KB
/
my-circe.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
;;; my-circe --- Configuartion for Circe IRC client
;;
;;; Commentary:
;;
;; This contains basic account configuration for Circe. I do use
;; the tracking utility for things like compile buffers as well.
;;
;;; Code:
(require 'use-package)
(require 'my-vars)
(require 'my-utils)
(require 'my-spell)
(require 'tls)
(require 'nsm)
(defun my-bitlbee-password (server)
"Return the password for the `SERVER'."
(my-pass-password "bitlbee"))
(defun my-znc-freenode-password (server)
"Return the password for the `SERVER'."
(format "ajb-linaro/Freenode:%s"
(my-pass-password "znc")))
(defun my-znc-oftc-password (server)
"Return the password for the `SERVER'."
(format "ajb-linaro/oftc:%s"
(my-pass-password "znc")))
(defun my-znc-libera-password (server)
"Return the password for the `SERVER'."
(format "ajb-linaro/libera:%s"
(my-pass-password "znc")))
(defun my-znc-libera-codelinaro-password (server)
"Return the password for the `SERVER'."
(format "ajb-linaro/libera:%s"
(my-pass-password "znc-admin@codelinaro")))
(defun my-znc-oftc-codelinaro-password (server)
"Return the password for the `SERVER'."
(format "ajb-linaro/oftc:%s"
(my-pass-password "znc-admin@codelinaro")))
;; These are both "personal" nicks for non-ZNC bounced connections
(defun my-freenode-nick-password (server)
"Return the password for the `SERVER'."
(my-pass-password "freenode-nick"))
(defun my-oftc-nick-password (server)
"Return the password for the `SERVER'."
(my-pass-password "[email protected]"))
(defun my-libera-nick-password (server)
"Return the password for the `SERVER'."
(my-pass-password "[email protected]"))
(defun my-gitter-password (server)
"Return the password for the `SERVER'."
(my-pass-password "gitter-irc"))
;; Logging
(use-package lui-logging
:commands enable-lui-logging)
(defvar my-logged-chans
'("#qemu@znc-oftc" "#qemu-gsoc@znc-oftc" "#linaro-virtualization@znc-libera" "#linaro-tcwg@znc-freenode")
"List of channels which I log")
(defun my-maybe-log-channel ()
"Maybe start logging the an IRC channel."
(when (-contains? my-logged-chans (buffer-name))
(enable-lui-logging)))
(defun my-check-for-meeting ()
"Check for start/endmeeting and enable appropriately."
(unless (-contains? my-logged-chans (buffer-name))
(save-excursion
(goto-char 0)
(if (re-search-forward "#startmeeting" nil t)
(enable-lui-logging)
(goto-char 0)
(if (and (re-search-forward "#endmeeting" nil t) lui-logging-timer)
(disable-lui-logging))))))
;; Lui
(use-package lui
:config (setq lui-flyspell-p t)
:hook (lui-pre-input . my-check-for-meeting))
(defun lui-autopaste-service-private-linaro (text)
"Paste TEXT to (private) pastebin.linaro.org and return the paste url."
(let ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")
("Referer" . "https://pastebin.linaro.org")))
(url-request-data (format "text=%s&language=text&webpage=&private=on"
(url-hexify-string text)))
(url-http-attempt-keepalives nil))
(let ((buf (url-retrieve-synchronously
"https://pastebin.linaro.org/api/create")))
(unwind-protect
(with-current-buffer buf
(goto-char (point-min))
(if (re-search-forward "\\(https://pastebin.linaro.org/view/.*\\)" nil t)
(match-string 1)
(error "Error during pasting to pastebin.linaro.org")))
(kill-buffer buf)))))
(defun lui-autopaste-service-linaro (text)
"Paste TEXT to (private) pastebin.linaro.org and return the paste url."
(let ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")
("Referer" . "https://pastebin.linaro.org")))
(url-request-data (format "text=%s&language=text"
(url-hexify-string text)))
(url-http-attempt-keepalives nil))
(let ((buf (url-retrieve-synchronously
"https://pastebin.linaro.org/api/create")))
(unwind-protect
(with-current-buffer buf
(goto-char (point-min))
(if (re-search-forward "\\(https://pastebin.linaro.org/view/.*\\)" nil t)
(match-string 1)
(error "Error during pasting to pastebin.linaro.org")))
(kill-buffer buf)))))
(defvar my-find-paste-url
(rx (:
">"
(group (: "paste.debian.net/" (one-or-more (in digit))))
"</a>"))
"Regexp to extract result URL from response. We need to fish it out
from the returned page like savages.")
(defun lui-autopaste-service-debian (text)
"Paste TEXT to paste.debian.net return the paste url."
(let ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")
("Referer" . "https://paste.debian.net")))
(url-request-data (format "code=%s&lang=text&expire=604800"
(url-hexify-string text)))
(url-http-attempt-keepalives nil))
(let ((buf (url-retrieve-synchronously
"https://paste.debian.net")))
(unwind-protect
(with-current-buffer buf
(goto-char (point-min))
(if (re-search-forward my-find-paste-url nil t)
(format "http://%s" (match-string 1))
(error "Error during pasting to paste.debian.net")))
(kill-buffer buf)))))
;; Auto pasting
(use-package lui-autopaste
:commands enable-lui-autopaste
:custom (lui-autopaste-function 'lui-autopaste-service-debian
"Use debian.net for pasting"))
;; Auto join everything
(defvar my-irc-login-timer
nil
"Timer for login.")
(defun my-irc-login ()
"Login into my usual IRCs."
(interactive)
(circe-lagmon-mode)
(when I-am-at-work
(circe "znc-cl-libera")
(circe "znc-cl-oftc")
;; (circe "bitlbee")
)
(circe "Pl0rt"))
(defun my-disable-irc-login ()
"Disable an idle login."
(interactive)
(when my-irc-login-timer
(cancel-timer my-irc-login-timer)))
;; Find and capture logins
(defun my-ssh-to-server ()
"Login to a server mentioned in buffer."
(interactive)
(let ((host (my-capture-login)))
(when host
(shell-command-to-string
(format "tmux new-window -a -n %s 'ssh %s'" host host)))))
(use-package circe
:ensure t
:commands (circe circe-set-display-handler)
:bind (:map circe-query-mode-map
("C-c C-c" . my-ssh-to-server))
:hook ((circe-channel-mode . enable-lui-autopaste)
(circe-channel-mode . my-maybe-log-channel))
:requires my-tracking
:init (when (and I-am-at-work
(daemonp)
(not I-am-root)
(not my-irc-login-timer))
;; override cert check for pl0rt
(let ((id (nsm-id "irc.pl0rt.org" 6697)))
(setq nsm-temporary-host-settings
(list (list :id id :conditions '(:no-host-match :expired :invalid :verify-cert)))))
(setq my-irc-login-timer (run-with-idle-timer 120 nil 'my-irc-login)))
:config
(progn
(when I-am-on-server
(setq circe-default-nick "stsquad"
circe-default-user "stsquad"
circe-default-realname "stsquad"))
;; override cert check for pl0rt
(let ((id (nsm-id "irc.pl0rt.org" 6697)))
(setq nsm-temporary-host-settings
(list (list :id id :conditions '(:no-host-match :expired :invalid :verify-cert)))))
(setq circe-reduce-lurker-spam t
circe-network-options
`(("Freenode"
:host "chat.freenode.net"
:server-buffer-name "⇄ Freenode"
:port "6697"
:tls t
:nick "stsquad"
:nickserv-password my-freenode-nick-password
)
("OFTC"
:host "irc.oftc.net"
:server-buffer-name "⇄ OFTC"
:port "6697"
:tls t
:nick "stsquad"
:nickserv-password my-oftc-nick-password
:channels ("#debian-devel" "#debian-cross")
)
("Libera Chat"
:host "irc.libera.chat"
:server-buffer-name "⇄ Libera Chat"
:port "6697"
:tls t
:nick "stsquad"
:nickserv-password my-libera-nick-password
)
("znc-cl-oftc"
:host "irc.codelinaro.org"
:server-buffer-name "⇄ OFTC (ZNC/CL)"
:port "6697"
:tls t
:pass my-znc-oftc-codelinaro-password
;; NickServ is handled by ZNC and the SASL login
:channels ("#qemu" "#qemu-gsoc")
)
("znc-cl-libera"
:host "irc.codelinaro.org"
:server-buffer-name "⇄ Libera Chat (ZNC/CL)"
:port "6697"
:tls t
:pass my-znc-libera-codelinaro-password
;; NickServ is handled by ZNC and the SASL login
)
("gitter"
:host "irc.gitter.im"
:server-buffer-name "⇄ Gitter (irc gateway)"
:port "6697"
:nick "stsquad"
:pass my-gitter-password
:tls t
)
("Pl0rt"
:host "irc.pl0rt.org"
:server-buffer-name "⇄ Pl0rt"
:port "6697"
:nick "ajb"
:use-tls t
:channels ("#blue")
)
("bitlbee"
:nick "ajb"
:server-buffer-name "⇄ bitlbee"
;; :pass my-bitlbee-password
:nickserv-password my-bitlbee-password
:nickserv-mask "\\(bitlbee\\|root\\)!\\(bitlbee\\|root\\)@"
:nickserv-identify-challenge "use the \x02identify\x02 command to identify yourself"
:nickserv-identify-command "PRIVMSG &bitlbee :identify {password}"
:nickserv-identify-confirmation "Password accepted, settings and accounts loaded"
:channels ("&bitlbee")
; does this set circe-lagmon-disabled in the server buffer?
:lagmon-disabled t
:host "localhost"
:service "6667")
("Slack"
:nick "alex.bennee"
:server-buffer-name "⇄ Slack"
:host "localhost"
:service "9007")))))
(use-package circe-chanop
:after circe)
(use-package circe-color-nicks
:after circe
:init (enable-circe-color-nicks))
(provide 'my-circe)
;;; my-circe.el ends here