IceChat Forums

IceChat 5 Scripting => Scripting => Topic started by: Morio on August 08, 2005, 07:05:13 AM

Title: very simple script
Post by: Morio on August 08, 2005, 07:05:13 AM
I have exactly zero experience in scripting, and I'd appreciate if someone could give me a script that causes med to reply but I'd like the script to work only on one channel

for example:

<someone> hello
<me> hello someone

and/or

<someone> icecream
<me> i like icecream
Title: Re: very simple script
Post by: Morio on August 08, 2005, 12:55:51 PM
No need to reply, I got it

EDIT: Too soon to say I guess, I can get the script to display messages when someone else writes something, but not when I do it


Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)               
if Message = "hello" then                 
SendCommand "/msg " +channel+  " hello"  + Nickname , ServerNumber     
end if             
End Sub             
Title: Re: very simple script
Post by: Snerf on August 08, 2005, 04:08:12 PM
Yes, ONTEXT does not fire when you enter a channel message, only when someone else does it. The OutGongText event is fired when you type messages.
You said you wanted to do it for only 1 channel as well, so you would check "if Channel = "#mychannel" then" as well.
Title: Re: very simple script
Post by: Morio on August 09, 2005, 06:02:38 AM
Ok, thanks for the help

Next I would like it to read a specific line from a file

ex.

<someone> !line b
<me> "a specific line b in a file"
Title: Re: very simple script
Post by: Snerf on August 09, 2005, 06:29:47 AM
Use the identifier $read for this. $read(filename,linenumber)

So inside the script engine you use - Getidentifier("$read(filename,linenumber)")

The filename can just be the actual file name, if the file is in your IceChat5\Scripts folder, it does not need the path then.
Title: Re: very simple script
Post by: Morio on August 09, 2005, 07:42:45 AM
Thank you once again.

Use the identifier $read for this. $read(filename,linenumber)

So inside the script engine you use - Getidentifier("$read(filename,linenumber)")
Sorry for asking these stupid questions, but how do I get the bot to display the text on the line


I shall bother you people once more  :-)
How could I make a script that my bot would take commands only from me?

ex

<me>!op someone
<mybot> /mode #channel +o someone

and It should only work if I give the command

Also, can I get a script to load when I connect to a server?
Title: Re: very simple script
Post by: Snerf on August 09, 2005, 04:30:36 PM
Hmm, this is a "very simple script" ?  I dont think so,  :-P .

How do you want the bot to display the text, by sending a message back to the channel?

SendCommand "/msg " & Channel & " $read(filename, linenumber)",ServerNumber

If you only want it to work from you, ONTEXT passes Nickname and Host, so you can use either to check.

If NickName = "SomeNick" then ...

or

If Host = "ident@world.com" then ...

Its your own choice, or you can use both, if you want it most secure.
Title: Re: very simple script
Post by: Lostsoul on August 09, 2005, 06:22:19 PM
On the same subject.  I'm really lazy, is there some where i can download a bot?  I tried to write one but.....i got confused to say the least..
Title: Re: very simple script
Post by: Snerf on August 09, 2005, 06:31:58 PM
Nope, what you see in the Download Section for Scripts, is all that has been submitted.
Title: Re: very simple script
Post by: Lostsoul on August 09, 2005, 08:15:10 PM
Well, i also mean if you know of any other bots that are external from Icechat.
Title: Re: very simple script
Post by: Snerf on August 09, 2005, 09:30:37 PM
Just go on google and type "irc bot" .. tonnes of them are available.  But I do not know scripting for other programs, only IceChat.
Title: Re: very simple script
Post by: Morio on August 10, 2005, 01:24:59 AM
Ok, thank you once again, but I still won't get the $read thing to work

this is the full code

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then       
    Getidentifier("$read(test.txt,1)")                       
SendCommand "/msg " & channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           
Title: Re: very simple script
Post by: Snerf on August 10, 2005, 06:59:50 AM
Does "test.txt" exist in your IceChat5\Scripts folder?  Because that is where it needs to be, as I stated in an earlier message.
Title: Re: very simple script
Post by: Morio on August 10, 2005, 11:52:39 AM
Yes it does, and all I get is

<Moriobot> $read(test.txt, 1)
Title: Re: very simple script
Post by: Snerf on August 10, 2005, 03:17:17 PM
Ok, thank you once again, but I still won't get the $read thing to work

this is the full code

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then       
    Getidentifier("$read(test.txt,1)")                       
SendCommand "/msg " & channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           


You did it wrong, it should be like this.
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then                 
  SendCommand "/msg " & channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           
Title: Re: very simple script
Post by: Morio on August 11, 2005, 01:46:24 AM
I still get the same message
Title: Re: very simple script
Post by: Snerf on August 11, 2005, 06:48:35 AM
Try just $read(test.txt) , without the line number, and see what happens.
Title: Re: very simple script
Post by: Morio on August 11, 2005, 08:35:45 AM
<Moriobot> $read(test.txt)
Title: Re: very simple script
Post by: Snerf on August 11, 2005, 11:42:28 AM
Are you running IceChat 5.50 ? Because it is not parsing that $identifier, so that it was I suspect, as it is new to 5.50.
Title: Re: very simple script
Post by: Morio on August 11, 2005, 12:06:49 PM
I'm running IceChat 5.50 Build 010905
Title: Re: very simple script
Post by: Snerf on August 11, 2005, 01:37:37 PM
You know what, I realize the problem now, after doing some digging.
5.50 has a bug with $read , which I did manage to fix in 5.51.
I just never released the fix. I will upload the 5.51 version and I will
send you a message when that is done.

Sorry for all the confusion.
Title: Re: very simple script
Post by: Morio on August 12, 2005, 12:58:57 AM
ok, thank you for all the help
Title: Re: very simple script
Post by: Morio on August 12, 2005, 01:20:57 AM
fgs...still just the same message
Title: Re: very simple script
Post by: ADB on August 12, 2005, 02:24:22 AM
Ok, thank you once again, but I still won't get the $read thing to work

this is the full code

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then       
    Getidentifier("$read(test.txt,1)")                       
SendCommand "/msg " & channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           


You did it wrong, it should be like this.
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then                 
  SendCommand "/msg " & channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           


Shouldn't it be either

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then                 
  SendCommand "//msg " & Channel & " $read(test.txt, 1)", ServerNumber                 
end if                         
End Sub                           

or

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "H" then
  SendCommand "/msg " & Channel & " " & GetIdentifier("$read(test.txt, 1)"), ServerNumber                 
end if                         
End Sub                           

?
Title: Re: very simple script
Post by: Morio on August 12, 2005, 02:36:29 AM
thanks, that works, but in the en of the line I get a "1)"
and if I set the linenumber to "2" then I get "2)"
Title: Re: very simple script
Post by: Snerf on August 12, 2005, 07:04:48 AM
Yes, you need to remove the space in $read(text.txt, 2) .. it should be $read(text.txt,2) , no space between the comma and the line number.
Title: Re: very simple script
Post by: Morio on August 12, 2005, 07:19:14 AM
Now the script is working as it should, thanks for the help everyone
Title: Re: very simple script
Post by: AM3 on August 26, 2005, 10:17:03 AM
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "Hello" then
  SendCommand "/msg " & Channel & " " & GetIdentifier("$read(test.txt, 1)"), ServerNumber                 
end if                         
End Sub                           

This worked test.txt , answers "Hello"

Then i writte the new in the same place below and created new test2.txt in script folder:

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)                           
if Message = "HI 4 all" then
  SendCommand "/msg " & Channel & " " & GetIdentifier("$read(test2.txt, 1)"), ServerNumber                 
end if                         
End Sub                           

And when some one types Hi 4 all , the message cames "Hello" from first GetIdentifier("$read(test.txt, 1)"), ServerNumber but not from the test2.txt "Hi 4 you too"

whats the problem here?



Title: Re: very simple script
Post by: Snerf on August 26, 2005, 03:28:18 PM
First of all, you have spaces in your identifier call again.
Are you using 2 different ONTEXT sub's in the same script file?
Combine them into 1.