I don't have oper privileges on any irc network so I can't be certain of my response.
Your commands seem in some cases incomplete :-
eg. putserv "sajoin $target" should probably be putserv "sajoin $target #channelname"
In other cases in error :-
eg. you declare a bind proc as msg:GLINE then go on to define a proc named msg:Gline
I have tried to code two of the commands (sajoin and kill). Documentation suggests that the bot would need Csop privileges for sajoin command and IRCop privileges for kill command.
I have also included a catch for raw 481, which is what the bot would receive from the ircd if it tried to use either command but did not have the appropriate privileges.
I have also commented the code so that you can follow the logic and code the other commands in a similar manner. Note that, for completeness, other ircd error responses (besides RAW 481) may occur. What happens if you try to kill a nick that is frozen or not online. These are issues that would have to be addressed and accounted for if you want a 'complete' and competent script.
Code: Select all
# syntax /msg botnick sajoin ?nick? <channel>
# forces ?nick? to join <channel>
# acts on the script user in the absence of the optional argument ?nick?
# requires script user to have global owner bot flag
# requires bot to have Csop priviledges
bind MSG n sajoin msg:sajoin
proc msg:sajoin {nick uhost hand text} {
# declare as global and set command user for use in further error messages
global cmduser
set cmduser $nick
# unset the global variable cmduser in case of ircd response not occuring within a reasonable timescale
utimer 10 [list unset cmduser]
# remove any spurious leading/trailing space characters from the text arguments
set arguments [string trim $text]
# check the number of text arguments provided and assign variables accordingly
# notice the script user with error message if an incorrect number of arguments is provided
switch -- [llength [split $arguments]] {
1 {
set username $nick
set channel $arguments
}
2 {
set username [lindex [split $arguments] 0]
set channel [lindex [split $arguments] 1]
}
default {
putserv "NOTICE $nick :-error- correct syntax is /msg botnick sajoin ?nick? <channel>"
return 0
}
}
# check that the username argument provided is in the format of a valid irc nick
# otherwise notice the script user with error message
if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $username]} {
# check that the channel argument proovided is in the format of a valid irc channel
# otherwise notice the script user with error message
if {[regexp -- {^#} $channel]} {
# send the sajoin command to the ircd
putserv "sajoin $username $channel"
} else {putserv "NOTICE $nick :-error- $channel is not in the format of a valid irc channel"}
} else {putserv "NOTICE $nick :-error- $username is not in the format of a valid irc nick"}
return 0
}
# syntax /msg botnick kill <nick> ?reason?
# forcibly disconnects <nick> from all linked servers for ?reason? if specified
# provides default reason text if optional ?reason? argument is not specified
# requires script user to have global owner bot flag
# requires bot to have IRCop priviledges
bind MSG n kill msg:kill
proc msg:kill {nick uhost hand text} {
# declare as global and set command user for use in further error messages
global cmduser
set cmduser $nick
# unset the global variable cmduser in case of ircd response not occuring within a reasonable timescale
utimer 10 [list unset cmduser]
# remove any spurious leading/trailing space characters from the text arguments
set arguments [string trim $text]
# check the number of text arguments provided and assign variables accordingly
# notice the script user with error message if an incorrect number of arguments is provided
switch -- [llength [split $arguments]] {
0 {
putserv "NOTICE $nick :-error- correct syntax is /msg botnick kill <nick> ?reason?"
return 0
}
1 {
set username $arguments
set reason "no reason specified"
}
default {
set username [lindex [split $arguments] 0]
set reason [join [lrange [split $arguments] 1 end]]
}
}
# check that the username argument provided is in the format of a valid irc nick
# otherwise notice the script user with error message
if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $username]} {
# send the kill command to the ircd
putserv "kill $username $reason"
} else {putserv "NOTICE $nick :-error- $username is not in the format of a valid irc nick"}
return 0
}
# a raw 481 is received by the bot from the ircd server if it tries to use oper commands but does not have oper privileges
bind RAW - 481 msg:raw481
proc msg:raw481 {from keyword text} {
# allow use of global variable cmduser within this proc
global cmduser
# if the global variable cmduser exists, notice the command user and unset cmduser
if {[info exists cmduser]} {
putserv "NOTICE $cmduser :Permission denied, I do not have the correct irc operator privileges"
unset cmduser
}
return 0
}