1set doc_section WinPopUp
2set doc_type Server
3
4doc add "Scripts ($doc_type)/$doc_section" "~/.quirc/winpopup.tcl
5
6WinPopUp support for QuIRC
7
8This system is designed to keep track of your WinPopUp messages even when QuIRC isn't running, it will display them the next time you start QuIRC.  To use this, you must have smbclient installed and you must add the following line to your /etc/smb.conf file (replace HOME with the absolute path to your home directory):
9
10    message command = sh -c 'mv %s HOME/.quirc/winpopup; cd HOME/.quirc/winpopup; echo \"%f\" > `basename %s`.quirc_winpopup; echo \"%m\" >> `basename %s`.quirc_winpopup; cat `basename %s` >> `basename %s`.quirc_winpopup; rm `basename %s`'
11
12It would be best to load this script in QuIRC sometime before you set the message command line in the smb.conf file as it sets up a dir if needed.  Beware that the dir ~/.quirc/winpopup will be world-writeable.  If anyone has any better ideas on how to implement this other than creating a world-writeable dir, let me know (quirc@patearl.net)."
13
14doc add "Variables (Config)/WinPopUp/winpopup_checktime" "How often in milliseconds to check for new WinPopUp messages."
15config default winpopup_checktime 15
16if { [info vars ::dynamic::winpopup_checktime]=="" } { set ::dynamic::winpopup_checktime 15 }
17
18
19proc event_unload {} {
20    doc remove Variables/winpopup_checktime
21}
22
23# ALIASES
24
25# /winpopup
26doc add "Aliases ($doc_type)/$doc_section/winpopup" "/winpopup <host> <message>
27
28This command uses smbclient to send a WinPopUp message to the specified host."
29
30# This could handle IPs too... like smbclient -I 207.229.35.247 -M k9
31alias winpopup {
32    if { [llength [split $arg " "]]<2 } {
33	error "Usage: /winpopup <host> <message>"
34    }
35    set host [lindex [split $arg " "] 0]
36    set message [join [lrange [split $arg " "] 1 end]]
37    echo " \0030,2 WINPOPUP \003 smbclient says:\n[exec echo -n $message | smbclient -M $host]\n \0030,2 WINPOPUP \003 END" [pathname status]
38}
39
40proc checknow {} {
41    set filenames [glob -nocomplain "$::env(HOME)/.quirc/winpopup/*.quirc_winpopup"]
42    foreach file $filenames {
43	while { [file exists [string range $file 0 [expr [string first ".quirc_winpopup" $file]-1]]] } {}
44	set thefile [open $file "r"]
45        gets $thefile name
46        gets $thefile host
47        set data ""
48        while {![eof $thefile]} {
49            append data "[gets $thefile]\n"
50        }
51        set data [string range $data 0 [expr [string length $data]-2]]
52	close $thefile
53	if { [string match "*\n*" $data] } {
54	    echo " \0030,2 WINPOPUP \003 Message from $name@\00302$host\003:\n$data\n \0030,2 WINPOPUP \003 END"
55	} else {
56	    echo " \0030,2 WINPOPUP \003 Message from $name@\00302$host\003: $data"
57	}
58	file delete $file
59    }
60    after [set ::[index]::winpopup::checktime] ::[index]::winpopup::checknow
61}
62
63if { ![file exists "$env(HOME)/.quirc/winpopup"] } {
64    file mkdir "$env(HOME)/.quirc/winpopup"
65    exec chmod 777 "$env(HOME)/.quirc/winpopup"
66}
67
68set checktime $::dynamic::winpopup_checktime
69after $::dynamic::winpopup_checktime ::[index]::winpopup::checknow
70