savIRC has a few custom procedures that could help you out with your scripting. I will list the name of the Function along with the syntax, and arguments. In the syntax line, I will surround the argument with question marks (?). It is basically just a place holder for what you would really put in. Directly under the syntax line you will see the available arguments.
Name: Window
Syntax: Window ?window?
Arguments: 0 - Channel Window
1 - Query Window
2 - Dcc Chat Window
Here is a working example, that you can copy and paste into your functions.tcl file. To execute the command just type /test at the command line.
proc test {} {
global active id me
set w $active($me(id))
set type [Window $w]
if {$type == 0} {
echo Channel Window Detected
}
}
This next function will prove very useful to you, when trying to get the name of the current channel.
Name: GetChannel
Syntax: GetChannel ?window? ?id?
Here is a working example. For those of you who aren't programmers (yet), # is a comment. Which means the tcl compiler will ignore everything after the # mark.
proc activeChan {} {
global active me
set chan [GetChannel $active($me(id)) $me(id)]
#GetChannel is the command
#$active($me(id)) is the active connection with your id for the server
echo $chan
}
This basically works as the GetChannel procedure does, so to test it out, remove the GetChannel related code, and insert the GetQuery command. Then execute the command in a query window. This will return the nickname of the query window.
Name: GetQuery
Syntax: GetQuery ?window? ?id?
Same as GetChat but works with DCC Chats.
Name: GetChat
Syntax: GetChat ?window? ?id?
This will return the window name for channel and id.
Name: GetWinChan
Syntax: GetWinChan ?channel? ?id?
If you want to get the window name of channel #foobar for the connection with id=1 you would do this:
set w [GetWinChan #foobar 1]
Same as GetWinChan but for query windows.
Name: GetWinQuery
Syntax: GetWinQuery ?nick? ?id?
Same as GetWinChan but for query windows.
Name: GetWinChat
Syntax: GetWinChat ?nick? ?id?
Execute a command on the given connection. For commands that sends data to the server it's important when using multiple connections, that the data is sent to the right server.
Name: GetWinChat
Syntax: id ?command? ?param_list? ?id?
The active command gets 3 arguments: