Request from RobertPlease help me a bit with this code snippet. Thanks my friend !
Users or Admins (of Bot) can be able to use Bot commands if and only if the following two conditions are:
1. Must be present in the channel #userbot or #botadmin
2. Ip/hostmask must be in the file list userbot.txt or botadmin.txt
Here is my code write by myself:
on *:text:#:{
if (!$read(BOTCOMMAND_CHAN.txt,nwt,$chan)) { return }
var %host $ial($nick).host
if ($read(userbot.txt,ntw,%host) && $nick ison #userbots) || ($read(botadmin.txt,ntw,%host) && $nick ison #botadmins) {
tokenize 32 ($1-)
if ($1 == ~command1) || ($1 == .command1) || ($1 == .command1) || ($1 == command1) {
....... (do command 1).......
if ($1 == ~command2) || ($1 == .command2) || ($1 == .command2) || ($1 == command2) {
....... (do command 2).......
if ($1 == ~command 3) || ( $1 == .command 3) || ($1 == !command 3) || ($1 == command3) {
........ (do command 3)......
.....
.....
}
}
}
;------------- file userbot.txt and botadmin.txt -------------
Ip/hostmask per line:
NickChat.users.undernet.org
102.245.32.51
254.114.52.78
........
------------------------------------------------------------------------------------------------------------------------------------------------------SolutionTry using this script code:
on *:TEXT:*:#:{
if (!$read($file_bcc,ntw,$chan)) { return }
if (!$on_access($ial($nick).host)) { return }
if (!$on_chan(#userbot,#botadmin)) { return }
;----------------------------------------
if (command1 isin $1 && $is_pref($1,!.~)) {
echo -a 30test:38 $chan $nick - do $1
}
if (command2 isin $1 && $is_pref($1,!.~)) {
echo -a 30test:38 $chan $nick - do $1
}
if (command3 isin $1 && $is_pref($1,!.~)) {
echo -a 30test:38 $chan $nick - do $1
}
}
alias -l file_bcc { return $scriptdir\botcomchan.txt }
alias -l file_user { return $scriptdir\userbot.txt }
alias -l file_admin { return $scriptdir\botadmin.txt }
alias -l on_access { if ($read($file_user,ntw,$1)) || ($read($file_admin,ntw,$1)) return $true }
alias -l on_chan { var %i 1 | while (%i <= $0) { if ($nick ison $eval($+($,%i),2)) return $true | inc %i } }
alias -l is_pref { if ($1) || ($left($1,1) isin $2) return $true }
Note: All files related to this script should be located in the same folder where the script itself is located. Take this as a rule for the future.