File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ WeeChat + Weeaboo faces = *Weechataboo*
3
3
4
4
A [ WeeChat] ( https://weechat.org/ ) -Script to replace emotion-tags with
5
5
random emoticon. Emotion tags in text are starting with ` ~~ ` . The text
6
- ` hello ~~hug ` will be ` hello (っ´▽`)っ ` . \
6
+ ` hello ~~hug ` will be ` hello (っ´▽`)っ ` .
7
+
7
8
Oh. It's written in Scheme.
8
9
9
10
```
Original file line number Diff line number Diff line change 17
17
; For usage see `/help weechataboo`
18
18
19
19
(use-modules (srfi srfi-1))
20
- (use-modules (ice-9 regex))
21
20
22
21
; -> List
23
22
; Returns a list of available emotions.
37
36
; Replaces in the given string every ~~EMOTION with a fitting emoticon.
38
37
(define (emoticonize-line line )
39
38
(let*
40
- ((match->emoticon (lambda (m ) (emotion->emoticon (string-drop m 2 ))))
41
- (match-func (lambda (m ) (match->emoticon (match:substring m))))
42
- (regexp (string-append " ~~(" (string-join (emotion-categories) " |" ) " )" )))
43
- (regexp-substitute/global #f regexp line 'pre match-func 'post )))
39
+ ((as-tag (lambda (emo ) (string-append " ~~" emo)))
40
+ (has-emotions? (lambda (txt )
41
+ (any (lambda (emo )
42
+ (number? (string-contains txt (as-tag emo))))
43
+ (emotion-categories))))
44
+ (replace (lambda (emo txt )
45
+ (let ((pos (string-contains txt (as-tag emo))))
46
+ (if (number? pos)
47
+ (string-replace
48
+ txt (emotion->emoticon emo)
49
+ pos (+ (string-length (as-tag emo)) pos))
50
+ txt))))
51
+ (new-line (fold replace line (emotion-categories))))
52
+ (if (has-emotions? new-line)
53
+ (emoticonize-line new-line)
54
+ new-line)))
44
55
45
56
; Pointer String String -> Weechat-Return
46
57
; This function was registered to be called when an input was submitted and
You can’t perform that action at this time.
0 commit comments