aboutsummaryrefslogtreecommitdiff
path: root/gitgud-chat.tcl
blob: 26439df9f8eff6ec8e24b8151a2d75e439225320 (about) (plain) (blame)
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
bind pubm * "#gitgud *" gitgud-privmsg

proc gitgud-privmsg {nick uhost hand chan text} {
  if {([string index $text 0] == "!") && (([string index $text 1] != " ") && ([string length $text] != "1"))} {
      return 0
  }

  if {([string match "*@hackint/user/h2ibot" $uhost])} {
      return 0
  }

  if {([string match "*@hackint/user/nullbot" $uhost])} {
      return 0
  }

  if {([string match "*@hackint/user/kh2i" $uhost])} {
      return 0
  }

  if {[string index $text 0] == "\001"} {
            return 0
  }

  if {[isop $nick $chan]} {
    set nick "@$nick"
  } elseif {[isvoice $nick $chan]} {
    set nick "+$nick"
  }

  putserv "PRIVMSG #gitgud-chat :<$nick> $text"
}

bind ctcp * "ACTION" gitgud-action

proc gitgud-action {nick uhost hand dest keyword text} {
  if {$dest == "#gitgud"} {
    if {[isop $nick $dest]} {
      set nick "@$nick"
    } elseif {[isvoice $nick $dest]} {
      set nick "+$nick"
    }
    putserv "PRIVMSG #gitgud-chat :\001ACTION <$nick> $text\001"
  }
}

bind notc * "*" gitgud-notice

proc gitgud-notice {nick uhost hand text {dest ""}} {
  if {$dest == "#gitgud"} {
    if {[isop $nick $dest]} {
      set nick "@$nick"
    } elseif {[isvoice $nick $dest]} {
      set nick "+$nick"
    }
    putserv "NOTICE #gitgud-chat :<$nick> $text"
  }
}

bind out * "% sent" gitgud-out

proc gitgud-out {queue text status} {
  set botnick $::botnick
  if {[botisop "#gitgud"]} {
    set botnick "@$botnick"
  } elseif {[botisvoice "#gitgud"]} {
    set botnick "+$botnick"
  }
  if {[string match "PRIVMSG #gitgud *" $text]} {
    if {[string match "*\\\[remind\\\]*" $text]} {
      putserv "PRIVMSG #gitgud-chat :<$botnick> [join [lrange [split $text ":"] 1 end] ":"]"
    }
  }
  if {[string match "NOTICE #gitgud *" $text]} {
    if {[string match "*\\\[karma\\\]*" $text]} {
      putserv "NOTICE #gitgud-chat :<$botnick> [join [lrange [split $text ":"] 1 end] ":"]"
    }
  }
}
s="w"> {$flag == "1"} { putdcc $idx "Removed server $rem from k-lined server list." } } proc remove_kservers {module} { global kfile global server servers if {[catch {set fd [open $kfile r]}] != 0} { set fd [open $kfile w] close $fd set fd [open $kfile r] } while {![eof $fd]} { set from [string trim [gets $fd]] set name "*$from*" if {[eof $fd]} {break} for {set j 0} {$j >= 0} {incr j} { set x [lsearch $servers $name] if {$x >= 0} { set servers [lreplace $servers $x $x] } if {$x < 0} { if {$j >= 0} { putlog "Removed server: $from" } break } } } close $fd return 1 } proc woah_klined {from keyword arg} { global kfile global server servers set kservers {} set fd [open $kfile r] while {![eof $fd]} { set tmp [gets $fd] if {[eof $fd]} {break} set kservers [lappend kservers [string trim $tmp]] } close $fd set flag "0" foreach tmp $kservers { if {$tmp == $from} { set flag "1" } } if {$flag != "1"} { set fd [open $kfile a] puts $fd $from close $fd } set name "*$from*" for {set j 0} {$j >= 0} {incr j} { set x [lsearch $servers $name] if {$x >= 0} { set servers [lreplace $servers $x $x] } if {$x <= 0} { if {$j >= 0} { putlog "Removed server: $from" } break } } return 1 } putlog "TCL loaded: k-lined" remove_kservers server