Bot Skeleton 2
Posted by HellRaz0r
Friday, July 20, 2007
Description: Bot Template
on *:start:{
set %bot-nick BotNick
set %bot-server irc.address.com
set %bot-network NetWork
set %bot-master *!*@addr1 *!*@addr2
set %bot-chan #chan
set %bot-authserv user pass
nick %bot-nick
server %bot-server
if (!%bot-trig) set %bot-trig @
if (!%bot-skin) set %bot-skin 1
if ($exists(binds.db)) {
hmake binds
hload binds binds.db
}
}
on *:connect:{
if ($network == %bot-network) {
mode $me +x
if (%bot-authserv) as auth $v1
if (%bot-chan) join $v1
}
}
on *!:part:%bot-chan:{ .hdel -sw ChanServ-Users $wildsite }
on *:quit:{ .hdel -sw ChanServ-Users $wildsite }
on *:text:*:%bot-chan:{
.hadd -mu5 OnText nick $nick
.hadd -mu5 OnText chan $chan
.hadd -mu5 OnText wildsite $wildsite
if (%bot-trig $+ * iswm $1) {
if (!$hget(ChanServ-Users,$wildsite)) {
hadd -mu3 CS-GetLevel-Text $nick $1-
hadd -mu3 CS-GetLevel nick $nick
ChanServ a $chan $nick
}
else signal OnText $1-
}
}
on *^:notice:*:*:{
var %nick $hget(Cs-GetLevel,nick), %text = $hget(CS-GetLevel-Text,%nick)
if ($nick == ChanServ) {
haltdef
if (* (*) has access * in #* iswm $1-) {
hadd -m ChanServ-Users $address(%nick,2) $strip($5)
.timer 1 1 signal OnText %text
.hfree -sw CS-GetLevel
.hfree -sw CS-GetLevel-Text
}
}
}
on *:signal:OnText:{
var %nick = $hget(OnText,nick), %chan = $hget(OnText,chan), %wildsite = $hget(OnText,wildsite)
var %cslevel = $iif($hget(ChanServ-Users,%wildsite),$v1,0)
var %master = $iif($istok(%bot-master,%wildsite,32),1,0)
var %isop = $iif(%nick isop %chan,1,0), %isvoice = $iif(%nick isvoice %chan,1,0)
if (%bot-trig $+ * !iswm $1) halt
tokenize 32 $right($1-,-1)
if ($hget(Binds,$1-)) msg %chan $skin(%bot-skin,$1,$v1)
elseif ($1- == A) notice %nick $skin(%bot-skin,$1,Your access level: %cslevel)
elseif ($1 == Bind) && ((%cslevel >= 400) || (%master)) {
if (!$3) {
var %error = Invalid syntax, use like this: %bot-trig $+ Bind <Name> <Text>
notice %nick $skin(%bot-skin,$1,%error)
}
else {
hadd -m Binds $2 $3-
hsave Binds binds.db
notice %nick $skin(%bot-skin,$1,Successfully bound $qt($2) to $qt($3-))
}
}
elseif ($1 == Unbind) && ((%cslevel >= 400) || (%master)) {
if (!$2) {
var %error = Invalid syntax, use like this: %bot-trig $+ Unbind <Name>
notice %nick $skin(%bot-skin,$1,%error)
}
elseif (!$hget(binds,$2)) notice %nick $skin(%bot-skin,$1,That bind doesnt exist.)
else {
hdel -sw binds $2
hsave Binds binds.db
notice %nick $skin(%bot-skin,$1,Successfully unbound $qt($2))
}
}
elseif ($1- == Binds) || ($1- == Commands) && ((%cslevel >= 300) || (%master)) {
var %x = 1, %t = %bot-trig, %cmds = %t $+ Bind %t $+ Binds %t $+ Unbind - %t $+ Set <Trigger|Skin|Topic> - %t $+ Topic
while ($hfind(binds,*,%x,w)) {
var %bind = $v1, %binds = %binds $iif($1 == Commands,@ $+ %bind,%bind)
inc %x
}
if (%binds) notice %nick $skin(%bot-skin,$1,$iif($1 == binds,%binds,%cmds - %binds))
elseif ($1 == Commands) notice %nick $skin(%bot-skin,$1,%cmds)
else notice %nick $skin(%bot-skin,$1,No binds exist.)
}
elseif ($1 == Set) && ((%cslevel >= 400) || (%master)) {
if ($2 == Trigger) && (%master) {
if (!$3) {
var %error = Invalid syntax, use like this %bot-trig $+ Set Trigger <Character>
notice %nick $skin(%bot-skin,$1-2,%error)
}
elseif ($len($3) > 1) notice %nick $skin(%bot-skin,$1,You must use a single character for the trigger.)
else {
set %bot-trig $3
notice %nick $skin(%bot-skin,$1-2,Successfully changed the trigger.)
}
}
elseif ($2 == Skin) && (%master) {
if ($3 !isnum 1-2) {
var %error = Invalid syntax, use like this: %bot-trig $+ Set Skin < $+ $v2 $+ >
notice %nick $skin(%bot-skin,$1-2,%error)
}
else {
set %bot-skin $3
notice %nick $skin(%bot-skin,$1-2,Successfully changed skin.)
}
}
elseif ($2 == Topic) {
if (!$3-) {
var %error = Invalid syntax, use like this: %bot-trig $+ Set Topic [Section] <Text>
notice %nick $skin(%bot-skin,$1-2,%error)
}
else {
_topic %chan $3-
notice %nick $skin(%bot-skin,$1-2,Successfully changed the topic.)
}
}
}
elseif ($1 == Topic) && (%isop) {
echo -a Topic
if (!$2-) {
var %error = Invalid syntax, use like this: %bot-trig $+ Topic [Section] <Text>
notice %nick $skin(%bot-skin,$1,%error)
}
else {
_topic %chan $2-
notice %nick $skin(%bot-skin,$1,Successfully changed the topic.)
}
}
elseif ($1 == Help) {
if ($2 == $null) notice %nick $skin(%bot-skin,$1,[^B]Help[^B]: %bot-trig $+ Help [Bind|Unbind|Binds|Set|Topic])
elseif ($2- == Bind) notice %nick $skin(%bot-skin,$+($1,->,$2),Binds some text to a command. - Syntax: %bot-trig $+ Bind <Name> <text>)
elseif ($2- == Unbind) notice %nick $skin(%bot-skin,$+($1,->,$2),Unbinds a command. - Syntax: %bot-trig $+ Unbind <Name>)
elseif ($2- == Binds) notice %nick $skin(%bot-skin,$+($1,->,$2),Shows the list of binds. - Syntax: %bot-trig $+ Binds)
elseif ($2- == Topic) notice %nick $skin(%bot-skin,$+($1,->,$2),Changes the specified Section or whole topic. - Syntax: %bot-trig $+ Topic [Section] <text>
elseif ($2 == Set) {
if ($3 == $null) notice %nick $skin(%bot-skin,$+($1,->,$2),Set: %bot-trig $+ Help Set [Trigger|Skin|Topic])
elseif ($3- == Trigger) notice %nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the bot command trigger. - Syntax: %bot-trig $+ Set Trigger <Character>)
elseif ($3- == Skin) notice %nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the bot skin. - Syntax: %bot-trig $+ Set Skin <1-2>)
elseif ($3- == Topic) notice %nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the specified Section or whole topic. - Syntax: %bot-trig $+ Set Topic [Section] <text>)
else notice %nick $skin(%bot-skin,$+($1,->,$2,->,$3),Help topic not found.)
}
else notice %nick $skin(%bot-skin,$1,Help topic not found.)
}
.hfree -sw OnText
}
alias _topic {
var %chan = $$1, %section = $$2, %text = $3-
var %topic = $chan(%chan).topic, %exp = /\Q $+ %section $+ \E:(?=(.*?)[^\s]+:|(.+))/i
if ($regex(%topic,%exp)) if ($regsubex(%topic,/( $+ %section $+ :)(.*?)((\S+:)|$)/i,\1 %text \3)) topic %chan $v1
else topic %chan $2-
}
alias skin {
if ($1 == 1) { return [^K]15,1[[^K]14,1«[^K]0,1»[^K]15,1 [^K]9 $+ $2 [^K]0,1«[^K]14,1»[^K]15,1]: [^K]4,1 $+ $3- $+ [^O] }
elseif ($1 == 2) { return [^K]15,1[[^K]14,1«[^K]0,1»[^K]15,1 [^K]4 $+ $2 [^K]0,1«[^K]14,1»[^K]15,1]: [^K]9,1 $+ $3- $+ [^O] }
else return $3-
}