~aleteoryx/tclircc

ref: eb4eaa5f637892f36ce8113163351d1f44ac4051 tclircc/main.tcl -rwxr-xr-x 1.0 KiB
eb4eaa5faleteoryx interceptors working a month ago
                                                                                
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
#!/bin/env tclsh

lappend auto_path /usr/lib/tcllib1.21
package require logger
set log [logger::init tclircc]

source irc.tcl
source cap.tcl

puts "connecting to testnet.ergo.chat"
set chan [irc::connect testnet.ergo.chat 6697 1]
#set chan [irc::connect localhost 8000 0]

irc::handler add $chan * {
  ${log}::debug [dict get $dispatch rawmsg]
}

proc nocap {dispatch} {
  if {[dict get $dispatch cmd] == "CAP"} {
    uplevel #0 {${log}::info "GET TROLLED, CAP BLOCKED"}
    return true
  }
}

irc::interceptor add $chan nocap

#irc::handler add $chan CAP {
#  ${log}::debug "parsing cap ls"
#  set parsed [cap::parse_msg [dict get $dispatch params]]
#  dict for {k v} $parsed {
#    if {$k == "caps"} {
#      ${log}::debug "$k:"
#      dict for {k v} $v {
#        ${log}::debug "  $k: $v"
#      }
#    } else {
#      ${log}::debug "$k: $v"
#    }
#  }
#}

cap::negotiate $chan
cap::support $chan message-tags

puts [irc::meta get $chan]

irc::listen on $chan

#${log}::info "requesting CAPs"
#irc::msg send $chan CAP LS 302

${log}::info "entering event loop"
vwait nil