115 |
# console modes, or nothing if that user isn't currently on the partyline |
# console modes, or nothing if that user isn't currently on the partyline |
116 |
# Module: core |
# Module: core |
117 |
proc ::tcldrop::dcc::console {idx {channel {}} {modes {}}} { |
proc ::tcldrop::dcc::console {idx {channel {}} {modes {}}} { |
118 |
if {"$channel$modes" == {}} { |
if {$idx == 0} { |
119 |
# Return their current console channel and modes. |
# The default console. |
120 |
# FixMe: If we don't have any set, then get it from the userfile. |
set changed 0 |
121 |
# FixMe: Or, if they don't have any console data in the userfile, |
set console [list - $::console - 1 0 0] |
122 |
# set it to sane defaults. |
} elseif {![catch { ::tcldrop::idx::GetInfo $idx console } console]} { |
123 |
if {$idx == 0} { |
# The current idx's console settings. |
124 |
# Return the default console: |
set changed 0 |
125 |
return [list - $::console - 1 0 0] |
} elseif {![catch { getuser [idx2hand $idx] console } console] && $console != {}} { |
126 |
} elseif {![catch { ::tcldrop::idx::GetInfo $idx console } console]} { |
# The console settings from the userfile. |
127 |
# Return the currently active console: |
set changed 1 |
128 |
return $console |
} elseif {![valididx $idx]} { |
129 |
} elseif {![catch { getuser [idx2hand $idx] console } console] && $console != {}} { |
return -code error {Invalid idx.} |
130 |
::tcldrop::idx::ChInfo $idx [list console $console] |
} else { |
131 |
# Return the console settings from the userfile: |
# The default console: |
132 |
return $console |
set changed 1 |
133 |
} else { |
set console [list - $::console - 1 0 0] |
|
# Return the default console: |
|
|
return [list - $::console - 1 0 0] |
|
|
} |
|
134 |
} |
} |
135 |
# Eggdrop treats $channel the same as $modes, and vice versa, so we'll do the same... |
# Eggdrop treats $channel the same as $modes, and vice versa, so we'll do the same... |
136 |
foreach whatever [list $channel $modes] { |
foreach whatever [list $channel $modes] { |
138 |
if {[validchan $whatever]} { |
if {[validchan $whatever]} { |
139 |
# They want to change their IRC console channel. |
# They want to change their IRC console channel. |
140 |
if {[matchattr [idx2hand $idx] vfomn|vfomn $whatever]} { |
if {[matchattr [idx2hand $idx] vfomn|vfomn $whatever]} { |
141 |
# FixMe: So change it. |
set changed 1 |
142 |
|
set console [lreplace $console 0 0 $whatever] |
143 |
} |
} |
144 |
} else { |
} else { |
145 |
# FixMe: They want to change their modes. |
set changed 1 |
146 |
|
set console [lreplace $console 1 1 [::tcldrop::MergeFlags $whatever [lindex $console 1]]] |
147 |
} |
} |
148 |
} |
} |
149 |
|
# Set the new console settings to the idx: |
150 |
|
if {$changed} { ::tcldrop::idx::ChInfo $idx [list console $console] } |
151 |
|
return $console |
152 |
} |
} |
153 |
|
|
154 |
# echo <idx> [status] |
# echo <idx> [status] |