View Single Post
Old 03-06-2005, 10:34 PM  
Threepw00d
Junior Member
 
Join Date: Jul 2003
Posts: 6
Default

Since I can't wait for HaRM to add iRC request to ioB2, I decided to write a little iRC request script myself. Its a bit rudimentary, I haven't spent much time refining/testing it so please forgive my lack of coding panache! :P

1. You need to be using latest versions of ioFTPD/ioB/ioA

2. in ioftpd.ini, under [FTP_Custom_Commands] section add:

################################################## #############################
# Additional custom commands to enable IRC requesting
reqirc = EXEC ..\scripts\ioA\ioA.exe REQUESTIRC
reqdelirc = EXEC ..\scripts\ioA\ioA.exe REQDELIRC
reqfilledirc = EXEC ..\scripts\ioA\ioA.exe REQFILLEDIRC
################################################## #############################

3.1 in iobanana.tcl, add the following binds in BINDS section:

################################################## #############################
# Additional Binds to enable IRC requesting
bind pub - $ioBvar(cmdpre)request proc_irc_request
bind pub - $ioBvar(cmdpre)reqdel proc_irc_reqdel
bind pub - $ioBvar(cmdpre)reqfilled proc_irc_reqfilled
################################################## #############################


3.2 in iobanana.tcl, add the following procs at the end:

################################################## ##############################
# Additional procs to enable IRC requesting
proc proc_irc_request {nick uhost hand chan args} {
global ioBvar
{if {[ioB:istrusted $uhost]} {
set nicksplit [split $nick {}]
set count 0
foreach alpha $nicksplit {
if {[string equal $alpha "\\"] || [string equal $alpha "\|"] } {
set nicksplit [lreplace $nicksplit $count $count]
incr count -1
}
incr count
}
set nick [join $nicksplit {}]
set arg [join[list $args "$nick@iRC"] "-"]
set status [catch {set ee [::ftp::Quote $ioBvar(ftp) SITE REQIRC $arg]} result]
if { $status == 0 } {
set output "-:[b]:[b] [c]$ioBvar(color1)request[c] [b]:[b]:- [b]\[REQ\]-%request[b] added by [b]%name[b]" ;
set output [ioB:replacevar $output "%name" $nick]
set output [ioB:replacevar $output "%request" $args]
set output [ioB:basicreplace $output "REQUEST"]
ioB:tsend chan $chan $output
}
}
}

proc proc_irc_reqdel {nick uhost hand chan args} {
global ioBvar
{if {[ioB:istrusted $uhost]} {
set arg [lindex $args 0]
if { [string is digit -strict $arg] } {
set status [catch {set ee [::ftp::Quote $ioBvar(ftp) SITE REQDELIRC $arg]} result]
set lines [split $ee \n]
set lines [lreplace $lines 0 0]
set lines [lreplace $lines end end]
set lines [lreplace $lines end end]
if { $status == 0 } {
if { [string equal [lindex $lines 0] "200- Request not found"] } {
set output "-:[b]:[b] [c]$ioBvar(color1)error[c] [b]:[b]:- Request number [b]$arg[b] not found: check !requests for correct request number"
ioB:tsend chan $chan $output
} else {
set output "-:[b]:[b] [c]$ioBvar(color1)request deleted[c] [b]:[b]:- request [b]%request[b] deleted by [b]%user[b]@iRC"
set output [ioB:replacevar $output "%user" $nick]
set output [ioB:replacevar $output "%request" $arg]
ioB:tsend chan $chan $output
}
}
} else {
set output "-:[b]:[b] [c]$ioBvar(color1)error[c] [b]:[b]:- Request number not found: $arg is not a number"
ioB:tsend chan $chan $output
}
}
}

proc proc_irc_reqfilled {nick uhost hand chan args} {
global ioBvar
set arg [lindex $args 0]
if { [string is digit -strict $arg] } {
set status [catch {set ee [::ftp::Quote $ioBvar(ftp) SITE REQFILLEDIRC $arg]} result]
set lines [split $ee \n]
set lines [lreplace $lines 0 0]
set lines [lreplace $lines end end]
set lines [lreplace $lines end end]
if { $status == 0 } {
if { [string equal [lindex $lines 0] "200- Request not found"] } {
set output "-:[b]:[b] [c]$ioBvar(color1)error[c] [b]:[b]:- Request number [b]$arg[b] not found: check !requests for correct request number"
ioB:tsend chan $chan $output
} else {
set lines [split [lindex $lines 0] :]
set reqfilled [string trim [lindex $lines 1]]
set output "-:[b]:[b] [c]$ioBvar(color1)filled request[c] [b]:[b]:- [b]\[%request\][b] > [b]\[REQ\]-%reqfilled[b] filled by [b]%user[b]@iRC"
set output [ioB:replacevar $output "%user" $nick]
set output [ioB:replacevar $output "%request" $arg]
set output [ioB:replacevar $output "%reqfilled" $reqfilled]
ioB:tsend chan $chan $output
}
}
} else {
set output "-:[b]:[b] [c]$ioBvar(color1)error[c] [b]:[b]:- Request number not found: $arg is not a number"
ioB:tsend chan $chan $output
}
}
################################################## ##############################

4. Add a user iRC/iRC, or even sitebot/sitebot will do (something to let you know that request was made from iRC). Then put that uID and gID into Request_IRC_Uid and Request_IRC_Gid in ioA.cfg. uID and gID is in \etc\UserIdTable and \etc\GroupIdTable.

5. this assumes that you are using ioB_colors.skin to display output. if you don't want colors remove [c]$ioBvar(color1) and the other [c] wherever you see it.

6. rehash (or restart) your bot, rehash site config (or restart ioFTPD).

7. test to make sure everything works as it should. add users to trusted list if you haven't already. only those users can !request or !reqdel who have been added in ioBanana.tcl in set ioBvar(trusted) {ident1@ip1 ident2@ip2}. All users can reqfill.

Features:

*Trusted users can make request in chan with !request <rls.name-grp>
*Request will be added as [REQ]-rls.name-grp-iRCNick@iRC. It shouldn't be too hard to customize that to your taste.
*Trusted users can delete request (which hasn't been !reqfilled) in chan with !reqdel <req number> (use !requests to check the rls. number)
*Users with pipe (|) or (\) in iRC nickname will have that character ripped off because Windows file system doesn't allow directories with those chars. So if someone has nickname |||\\\||| his name won't show up. Request made by |SpankMe| will look like [REQ]-rls.name-grp-SpankMe@iRC
*Everyone in chan can do !reqfilled <req number>
*Report bugs and suggestions here. I'll check back from time to time or the other accomplished coders can help you out too.
Threepw00d is offline   Reply With Quote