|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Can anyone help me with this remote. !Addcmd my bot will add this cmd into cmd.hsh. i.e: !Addcmd !wb my bot will add !wb into the cmd list of a channel in cmd.hsh. !Delcmd my bot will del this cmd from the cmd list of a channel in cmd.hsh. !listcmd my bot will list all the cmd are available in a channel from cmd.hsh. Finally, when someone type a cmd, example: !wb David_James is a channel, my bot will find this cmd of this channel and msg to channel back. I want this bot work for multiple channel. Sorry, for my bad English.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Im not sure what your asking for exactly 100% i had to read it a few times but... ;Setup
alias cmdlist {
hmake cmd $?="How many items? 30 is average"
hsave cmd cmd.hsh
}
Here you will have to type /cmdlist then press enter and load the cmd hsh table
;Usage
on *:TEXT:*:#: {
[color:green];Channel for all # channel for a few = #channel1,#channel2 etc... seperated always by a coma[/color]
if ($1 == !Addcmd) && (! == $left($2,+1)) {
hadd cmd $2
hsave cmd cmd.hsh
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
hdel cmd $2
hsave cmd cmd.hsh
}
else { msg $chan Sorry $nick $+ , I cannot add that to file or delete since it does not start by ! }
}
So far i included the ability to add and del cmd from hash file but im not sure how you want to use this your saying !WB David_James is a channel << this part i dont understand how you want the script to react to it...
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Okay, let me explain you more. When I type !Addcmd !wb Welcome to $chan $nick, my bot will add !wb Welcome to $chan $nick into cmd.hsh. If someone type !wb <nick>, my bot wil send Welcome to #Channel <nick> to the channel. And I also want to have !listcmd, that will list all availabl cmds are in the channel.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
I dont see that being possible at the moment to put something like !addcmd !wb Welcome to my channel $chan $nick
reason behind it it will psychially write $chan and $nick to the hash table.. ill look into it post if anything
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
I know I've seen something similar to this, but at the moment I can't find it. I'll post the link as soon as I find it, though. I've had no luck in finding the post I was mentioning, so here's a quick code that I think should work. I'm unable to test it at present. on *:start:{
if !$hget(Commands) { .hmake Commands 10 }
if $exists(Commands.hsh) { .hload Commands Commands.hsh }
}
on *:load:{
if !$hget(Commands) { .hmake Commands 10 }
if $exists(Commands.hsh) { .hload Commands Commands.hsh }
}
on *:text:!addcmd*:*:{
if $hget(Commands,$2) {
.msg $nick That command has already been entered
}
else {
.hadd -m Commands $2 $3-
}
}
on *:text:*:*:{
if $hget(Commands,$1) {
$eval($hget(Commands,$1))
}
}
on *:exit:{
.hsave -o Commands Commands.hsh
}
on *:disconnect:{
.hsave -o Commands Commands.hsh
}
Last edited by RusselB; 08/10/05 04:45 PM.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
well here to list commands ill do a simple loop to read commands
on *:TEXT:*:#: {
if ($1 == !listcmds) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(cmd,0).item) {
msg $nick $hget(cmd,%listcmds.inc).item
inc %listcmds.inc
}
}
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
This should suffice everything... usage /cmdlist ; to setup a cmd.hsh table hnick == $nick hchan == $chan !Addcmd cmdhere texthere ex:. !Addcmd !Wb Welcome back to hchan Enjoy your stay hnick !Delcmd cmdherewhichalreadyexist
on *:TEXT:*:#: {
if ($1 == !listcmds) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(cmd,0).item) {
msg $nick $hget(cmd,%listcmds.inc).item
inc %listcmds.inc
}
}
if (! isin $2) {
if ($1 == !Addcmd) && (! == $left($2,+1)) {
hadd cmd $2 $3-
hsave cmd cmd.hsh
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
hdel cmd $2
hsave cmd cmd.hsh
}
}
if (! isin $1) {
var %hreplace = $hget(cmd,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$active)
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
else { msg $chan %hreplace }
}
}
alias cmdlist {
hmake cmd $?="How many items? 30 is average"
hsave cmd cmd.hsh
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Well, it's close to what I need. The problem is that, my bot is on alot of channels, if I want each channel has its own cmd list, what should I do? I tested the script above, it has only one cmd list for every channel. And if it is possible, pls help to check if a !cmd is already existed, it won't add into cmd.hsh.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
try this
on *:TEXT:*:#: {
if (! isin $1) {
%active.chan = $replace($chan,$chr(291),h) $+ cmd
%active2.chan = %active.chan $+ .hsh
}
if ($1 == !listcmds) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(%active.chan,0).item) {
msg $nick $hget(%active.chan,%listcmds.inc).item
inc %listcmds.inc
}
}
if ($1 == !Addcmd) && (! == $left($2,+1)) {
if ($2 == $hfind(%active.chan,$2)) { msg $chan $nick you cannot add that command to file it already exist | halt }
else { hadd %active.chan $2 $3-
hsave %active.chan %active.chan $+ .hsh
msg $chan $nick $+ , I added Command ( $+ $2 $+ ) to file.
}
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
hdel %active.chan $2
hsave %active.chan %active.chan $+ .hsh
}
if (! isin $1) {
var %hreplace = $hget(%active.chan,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$chan)
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
else { msg $chan %hreplace }
}
}
alias cmdlist {
var %hchan = $replace($active,$chr(291),h) $+ cmd
hmake %hchan $?="How many items? 30 is average"
hsave %hchan %hchan $+ .hsh
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Well, it seems to work perfectly. The problem is on !listcmds and !delcmd. May you add more condition like. If there is no cmds in list, when user type !listcmds, it will say ' Cmds list is empty. ' And !delcmd, if use type !delcmd, if $2 is not in list, it will say ' $2 is not in the list '. And only user have mode ~,& and @ can use command !addcmd or !delcmd. Millions thanks to you Lpfix5.
Last edited by David_James; 09/10/05 06:23 PM.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
slight code edit
on *:TEXT:*:#: {
if (! isin $1) {
%active.chan = $replace($chan,$chr(291),h) $+ cmd
%active2.chan = %active.chan $+ .hsh
}
if ($1 == !listcmds) {
if ($hget(%active.chan,0).item == 0) { msg $chan Sorry $nick $+ , no commands stored in list }
if ($hget(%active.chan,0).item >= 1) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(%active.chan,0).item) {
msg $nick $hget(%active.chan,%listcmds.inc).item
inc %listcmds.inc
}
}
}
if ($nick isop $chan) {
if ($1 == !Addcmd) && (! == $left($2,+1)) {
if ($2 == $hfind(%active.chan,$2)) { msg $chan $nick you cannot add that command to file it already exist | halt }
else { hadd %active.chan $2 $3-
hsave %active.chan %active.chan $+ .hsh
msg $chan $nick $+ , I added Command ( $+ $2 $+ ) to file.
}
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
hdel %active.chan $2
hsave %active.chan %active.chan $+ .hsh
}
}
elseif ($nick !isop) { msg $chan You cannot use !addcmd or !Delcmd }
if ($1 == $hget(%active.chan,$1)) {
var %hreplace = $hget(%active.chan,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$chan)
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
else { msg $chan %hreplace }
}
}
alias cmdlist {
var %hchan = $replace($active,$chr(291),h) $+ cmd
hmake %hchan $?="How many items? 30 is average"
hsave %hchan %hchan $+ .hsh
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Here I've got some errrors: If a nick holding OP status does !addcmd or !delcmd, it's working fine. Example: <@David_James> !addcmd !Test Test <BotComs> David_James, I added Command (!Test) to file. but when I type !Test, it didn't work. Another error is that, when a regular user try to type !addcmd or !delcmd it showed message like this: * /if: invalid format (line 61, script12.ini)
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
im feeling a bit better i think a little now i noticed a few errors im my original script try that for now fixes current errors your talking about
on *:TEXT:*:#: {
if (! isin $1) {
%active.chan = $replace($chan,$chr(291),h) $+ cmd
%active2.chan = %active.chan $+ .hsh
}
if ($1 == !listcmds) {
if ($hget(%active.chan,0).item == 0) { msg $chan Sorry $nick $+ , no commands stored in list }
if ($hget(%active.chan,0).item >= 1) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(%active.chan,0).item) {
msg $nick $hget(%active.chan,%listcmds.inc).item
inc %listcmds.inc
}
}
}
if ($1 == !Addcmd) && (! == $left($2,+1)) {
if ($nick isop $chan) && ($2 == $hfind(%active.chan,$2)) { msg $chan $nick you cannot add that command to file it already exist | halt }
elseif ($nick isop $chan) { hadd %active.chan $2 $3-
hsave %active.chan %active.chan $+ .hsh
msg $chan $nick $+ , I added Command ( $+ $2 $+ ) to file.
}
else { msg $chan Unfortunently $nick $+ , you cannot add $2 to file you have 40% access to this script. }
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
if ($nick isop $chan) {
hdel %active.chan $2
hsave %active.chan %active.chan $+ .hsh
msg $chan I have removed ( $+ $2 $+ ) from file.
}
elseif ($2 == $hfind(%active.chan,$2)) { msg $chan Unfortunently $nick $+ , You cannot remove $2 from file you have 40% access to script }
}
if ($hget(%active.chan,$1)) {
var %hreplace = $hget(%active.chan,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$chan)
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
else { msg $chan %hreplace }
}
}
alias cmdlist {
var %hchan = $replace($active,$chr(291),h) $+ cmd
hmake %hchan $?="How many items? 30 is average"
hsave %hchan %hchan $+ .hsh
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
It works perfectly... Millions thanks for you, Lipfix5.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
No problem thats what im here for. also to cause less headaches a bit,.. put this script in also with that basically scans and sees if the file exist if so it loads it
on 1:JOIN:#: {
var %join.scan = $replace($chan,$chr(35),h) $+ cmd.hsh
if ($nick == $me) && ($exists(%join.scan) == $true) {
hmake %join.scan 30
hload %join.scan %join.scan $+ cmd.hsh
}
else { echo -a Did not find %join.scan $+ cmd.hsh on file }
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Er... a little more problem here. I added a cmd below: <@David_James> !addaction !wb $nick Welcome hnick to hchan. Now I tried to use !wb Funkie: <@David_James> !wb Funkie My bot replied: <MyBot> $nick Welcome Funkie to #funkie.
Forexample: If I use !wb Funkie, is there anyway to make it change to ' David_James Welcome Funkie to #funkie. ' Forexample: <nickA> !wb David_James <MyBots> nickA Welcome David_James to Channel.
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Easy... just remember the $replace functions... added new function hname which ='s $nick of person who original does the command
on *:TEXT:*:#: {
if (! isin $1) {
%active.chan = $replace($chan,$chr(291),h) $+ cmd
%active2.chan = %active.chan $+ .hsh
}
if ($1 == !listcmds) {
if ($hget(%active.chan,0).item == 0) { msg $chan Sorry $nick $+ , no commands stored in list }
if ($hget(%active.chan,0).item >= 1) {
var %listcmds.inc = 1
msg $nick Listing Commands...
while (%listcmds.inc <= $hget(%active.chan,0).item) {
msg $nick $hget(%active.chan,%listcmds.inc).item
inc %listcmds.inc
}
}
}
if ($1 == !Addcmd) && (! == $left($2,+1)) {
if ($nick isop $chan) && ($2 == $hfind(%active.chan,$2)) { msg $chan $nick you cannot add that command to file it already exist | halt }
elseif ($nick isop $chan) { hadd %active.chan $2 $3-
hsave %active.chan %active.chan $+ .hsh
msg $chan $nick $+ , I added Command ( $+ $2 $+ ) to file.
}
else { msg $chan Unfortunently $nick $+ , you cannot add $2 to file you have 40% access to this script. }
}
if ($1 == !Delcmd) && (! == $left($2,+1)) {
if ($nick isop $chan) {
hdel %active.chan $2
hsave %active.chan %active.chan $+ .hsh
msg $chan I have removed ( $+ $2 $+ ) from file.
}
elseif ($2 == $hfind(%active.chan,$2)) { msg $chan Unfortunently $nick $+ , You cannot remove $2 from file you have 40% access to script }
}
if ($hget(%active.chan,$1)) {
var %hreplace = $hget(%active.chan,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$chan[color:red],hname,$nick[/color])
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
[color:red] elseif (hname isin %hreplace) {
msg $chan $replace(%hreplace,hname,$nick)
}[/color]
else { msg $chan %hreplace }
}
}
alias cmdlist {
var %hchan = $replace($active,$chr(291),h) $+ cmd
hmake %hchan $?="How many items? 30 is average"
hsave %hchan %hchan $+ .hsh
}
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Well, it is not working. ------------- <@David_James> !addcmd !hi hname says hi to hnick. <BotComs> David_James, I added Command (!hi) to file. <CuTiE_KapEr> !hi David_James <BotComs> hname says hi to David_James. ------------- It didn't replace hname to CuTie_KapEr.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Heh... it's those elseif's causing the problem. Change:
if ($hget(%active.chan,$1)) {
var %hreplace = $hget(%active.chan,$1)
if (hnick isin %hreplace) && (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2,hchan,$chan,hname,$nick)
}
elseif (hnick isin %hreplace) {
msg $chan $replace(%hreplace,hnick,$2)
}
elseif (hchan isin %hreplace) {
msg $chan $replace(%hreplace,hchan,$chan)
}
elseif (hname isin %hreplace) {
msg $chan $replace(%hreplace,hname,$nick)
}
else { msg $chan %hreplace }
}
to:
if ($hget(%active.chan,$1)) {
var %hreplace = $replacex($hget(%active.chan,$1),hnick,$2,hchan,$chan,hname,$nick)
msg $chan %hreplace
}
Or, get rid of the variable altogether:
if ($hget(%active.chan,$1)) {
msg $chan $replacex($hget(%active.chan,$1),hnick,$2,hchan,$chan,hname,$nick)
}
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2005
Posts: 21
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2005
Posts: 21 |
Thanks Riamus. It works perfectly. And thanks Lpfix5 too. Too much job for you.
|
|
|
|
|