Skip to content

Commit

Permalink
More bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
DasBrain committed Jul 11, 2021
1 parent c4900f8 commit 0108818
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 24 deletions.
3 changes: 3 additions & 0 deletions braintools.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ package require dasbrain::chanopt
package require dasbrain::autorejoin
package require dasbrain::chanserv
package require dasbrain::quakenet
package require dasbrain::channels
package require dasbrain::users
package require dasbrain::automode
20 changes: 20 additions & 0 deletions dasbrain/autocycle-1.0.tm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package require hexchat

package require dasbrain::chanopt
package require dasbrain::channels

package provide dasbrain::autocycle 1.0

namespace eval ::dasbrain::autocycle {
copt register cycle flag 0
::dasbrain::channels::on-event postremove ::dasbrain::autocycle::POSTREMOVE
}

proc ::dasbrain::autocycle::POSTREMOVE {chan args} {
if {[dict exists $::dasbrain::channels::channels [::hexchat::prefs id] $chan] &&
[dict size [dict get $::dasbrain::channels::channels [::hexchat::prefs id] $chan users]] <= 1 &&
![::dasbrain::channels::meop $chan] &&
[ccopt get cycle]} {
::hexchat::command "CYCLE $chan"
}
}
47 changes: 29 additions & 18 deletions dasbrain/channels-1.0.tm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ proc ::dasbrain::channels::do-auth {chan userrec} {
emit-event chghandle $chan [dict get $channels $sid $chan users [dict get $userrec nick]]
}
}
::dasbrain::channels::on-event userchg ::dasbrain::channels::do-auth


proc ::dasbrain::channels::JOIN {word word_eol} {
Expand Down Expand Up @@ -141,7 +142,7 @@ proc ::dasbrain::channels::JOIN {word word_eol} {
dict for {k v} $userrec {
dict set channels $sid $chan users $nick $k $v
}
dict for {k v} [dict create prefix [dict create] flags [dict create H 1] jointime [clock seconds]] {
dict for {k v} [dict create prefix [dict create] flags [dict create] jointime [clock seconds]] {
if {![dict exists $channels $sid $chan users $nick $k]} {
dict set channels $sid $chan users $nick $k $v
}
Expand Down Expand Up @@ -396,17 +397,18 @@ proc ::dasbrain::channels::353 {word word_eol} {
set prefixes [isupport get PREFIX]
set prefixes [split [string range $prefixes [string first ) $prefixes]+1 end] {}]
foreach u [split $users] {
set userrec [dict create gotjoin 1]
if {$u eq {}} {continue}
set userrec [dict create gotjoin 1 flags {}]
while {[string index $u 0] in $prefixes} {
dict set userrec prefix [string index $u 0] 1
set u [string range $u 1 end]
}
set bangidx [string first ! $u]
if {$bangidx != -1} {
# we have userhost-in-names
dict set userrec uhost [string range $u $bangidx+1 end]
set u [string range $u 0 $bangidx-1]
}
while {[string index $u 0] in $prefixes} {
dict set userrec prefix [string index $u 0] 1
set u [string range $u 1 end]
}
dict set userrec nick $u
dict for {k v} $userrec {
dict set channels $sid $chan users $u $k $v
Expand All @@ -416,11 +418,12 @@ proc ::dasbrain::channels::353 {word word_eol} {
}

proc ::dasbrain::channels::ACCOUNT {word word_eol} {
set line [ircsplit [lindex $word_eol 1]]
lassign line from - account
set nick [nuh2nick $from]
variable channels
set sid [::hexchat::prefs id]
if {![dict exists $channels $sid]} {return}
set line [ircsplit [lindex $word_eol 1]]
lassign $line from - account
set nick [nuh2nick $from]
dict for {chan info} [dict get $channels $sid] {
if {[dict exists $info users $nick]} {
dict set channels $sid $chan users $nick account $account
Expand All @@ -431,6 +434,9 @@ proc ::dasbrain::channels::ACCOUNT {word word_eol} {
}

proc ::dasbrain::channels::AWAY {word word_eol} {
variable channels
set sid [::hexchat::prefs id]
if {![dict exists $channels $sid]} {return}
set line [ircsplit [lindex $word_eol 1]]
if {[llength $line] == 2} {
set away 0
Expand All @@ -439,8 +445,6 @@ proc ::dasbrain::channels::AWAY {word word_eol} {
set away-reason [lindex $line 2]
}
set nick [nuh2nick [lindex $line 0]]
variable channels
set sid [::hexchat::prefs id]
dict for {chan info} [dict get $channels $sid] {
if {[dict exists $info users $nick]} {
if {$away} {
Expand All @@ -458,12 +462,13 @@ proc ::dasbrain::channels::AWAY {word word_eol} {
}

proc ::dasbrain::channels::CHGHOST {word word_eol} {
variable channels
set sid [::hexchat::prefs id]
if {![dict exists $channels $sid]} {return}
set line [ircsplit [lindex $word_eol 1]]
lassign line from - user host
lassign $line from - user host
set nick [nuh2nick $from]
set newuhost ${user}@${host}
variable channels
set sid [::hexchat::prefs id]
dict for {chan info} [dict get $channels $sid] {
if {[dict exists $info users $nick]} {
dict set channels $sid $chan users $nick uhost $newuhost
Expand Down Expand Up @@ -498,10 +503,10 @@ proc ::dasbrain::channels::324 {word word_eol} {
set args [lassign $args param]
dict set chanmodes $mc $param
} elseif {$mc in $D} {
dict set chanmodes $mc 1
dict set chanmodes $mc {}
} else {
::hexchat::print "channels\tWarning: Unknown mode $mc in 324 numeric, assuming no parameter"
dict set chanmodes $mc 1
dict set chanmodes $mc {}
}
}
if {[llength $args] > 0} {
Expand Down Expand Up @@ -537,14 +542,20 @@ proc ::dasbrain::channels::mode-change {from chan mode arg type} {
}
}
} else {
dict unset channels [::hexchat::prefs id] $chan users $arg prefix $pc
set sid [::hexchat::prefs id]
if {[dict exists $channels $sid $chan users $arg prefix]} {
dict unset channels $sid $chan users $arg prefix $pc
}
}
}
default {
if {$pm eq {+}} {
dict set channels [::hexchat::prefs id] $chan mode $mc $arg
} else {
dict unset channels [::hexchat::prefs id] $chan mode $mc
set sid [::hexchat::prefs id]
if {[dict exists $channels $sid $chan mode]} {
dict unset channels [::hexchat::prefs id] $chan mode $mc
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dasbrain/dronebl-1.0.tm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ proc ::dasbrain::dronebl::gotdbl-response {sid chan userrec token} {
if {[dict exists $::dasbrain::channels::channels $sid $chan users $nick]} {
dict set ::dasbrain::channels::channels $sid $chan users $nick dronebl $reason
}
if {[::dasbrain::channels::meop $chan]} {
if {[::dasbrain::channels::meop $chan] && [dict exists $::dasbrain::channels::channels $sid $chan users $nick]} {
::hexchat::command "KICK $nick DRONEBL: $reason"
if {[dict exists $::dasbrain::channels::channels $sid $chan mode D]} {
::hexchat::print "DBL $nick\t$reason - kicked"
Expand Down
2 changes: 1 addition & 1 deletion dasbrain/modeparse-1.0.tm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ proc ::dasbrain::modeparse::parse {words words_eol} {
set type B
} elseif {$c in $C} {
set take [string equal $plusminus +]
set type B
set type C
} elseif {$c in $D} {
set take 0
set type D
Expand Down
11 changes: 7 additions & 4 deletions dasbrain/quakenet-1.0.tm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ package require dasbrain::need
package provide dasbrain::quakenet 1.0

namespace eval ::dasbrain::quakenet {
::dasbrain::chanopt::register cs-invite flag 0
::dasbrain::chanopt::register cs-unban flag 0
::dasbrain::chanopt::register cs-voice flag 0
::dasbrain::chanopt::register cs-op flag 0
::dasbrain::chanopt::register q-invite flag 0
::dasbrain::chanopt::register q-unban flag 0
::dasbrain::chanopt::register q-voice flag 0
::dasbrain::chanopt::register q-op flag 0

::dasbrain::need::handler ::dasbrain::quakenet::need
}
Expand All @@ -19,6 +19,9 @@ proc ::dasbrain::quakenet::need {what channel} {
set what invite
}
if {[copt get [::hexchat::getinfo network] $channel q-$what] eq {1}} {
if {$what eq {unban}} {
set what unbanme
}
::hexchat::command "RAW PRIVMSG [email protected] :$what $channel"
if {$what eq {invite}} {
::dasbrain::invitejoin::addjoin $channel
Expand Down

0 comments on commit 0108818

Please sign in to comment.