Author Topic: Direction for beginner scripting  (Read 5629 times)

BrazilianGal

  • Newbie
  • *
  • Posts: 4
Direction for beginner scripting
« on: May 04, 2006, 10:11:12 PM »
I must (use) stay within Icechat5 or 5.5 >  I am kinda handy when it comes to puting things together..but this chat is differnet from previous work.. Can someone please point me in the right direction what commands I should experiment with etc..  I think it is a script that I need.. that will recognize a format such as set amount of 6 random characters ###### a series of letters and numbers when a chat user posts it, this bot, or script (or whatever) can recognize it for that specific string/code I need, then send it to a file, on my C:.. I could even ask my users to preface it with an (>dont mean to use Icechats term, but it makes sense for what i am describing>) identifier like 2 brackets "[[73jdh3"  So an example.. "[[54iss4" would either be sent to a file as plaintext. save it and close it(preferably unnoticed, uninterrupting, and in the background.  And for extra brownie points, and to be even more sophisticated, have the file change names so once 6code.txt was created, have 6code01.txt then 6code02.txt  etc... for 20 files etc, with a simple code in that text file.  I'm sure this is childsplay to most of you.  Snerf, I have been reading your posts, yer a genius at this...all of the helpful posts I have read.  Thank you please, love you all!!! :-)
« Last Edit: May 04, 2006, 10:16:52 PM by BrazilianGal »

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Direction for beginner scripting
« Reply #1 on: May 04, 2006, 11:32:16 PM »
Well, I don't really understand what you want, I guess I find the explanatiion too confusing.
The IceChat God

BrazilianGal

  • Newbie
  • *
  • Posts: 4
Re: Direction for beginner scripting
« Reply #2 on: May 05, 2006, 09:27:47 AM »
I have 20 users and at any given time they will put in the chatroom a code that I need saved to a remote file for later usage.  I can later pick up this file and use the contents in another application. Where Icechat comes in, is hopefully it would recognize this code and place it in a text file and auto save it to my harddrive.  I was hoping it would be something I could run locally, and my remote users would not be bothered with this.  Maybe it is similar to how you would detect foul language. anywhere this string of characters comes through the chat window, realtime, it would be saved as a text file, and then later I could use it.  I have a need to collect these. and instead of me trying to be fast, and copy them one by one, I could let Icechat (script?) grab them for me, and save for later.

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Direction for beginner scripting
« Reply #3 on: May 05, 2006, 09:59:57 AM »
Ok. Let me see if I follow this.
A user types a random 6 character code, ie: "abc123"

They type this in a channel. Is it just this code, or is there other text as well?

Do you know want a file created, called "abc123.txt" , with something inside the file?

Or, do you want "abc123" added to a specific file name with a different name?

Thats where I am confused.

Also confusing is what you meant by the extra brownie point, in creating 6code01.txt, 6code02.txt?

So, if you could explain it even more so, I could help you. But I am still a bit lost as what the files names are
and what you want saved inside the files.

Btw, this is quite easily done, its just a matter of getting the specifics right before a script can be made :)
The IceChat God

BrazilianGal

  • Newbie
  • *
  • Posts: 4
Re: Direction for beginner scripting
« Reply #4 on: May 05, 2006, 11:33:25 AM »


I thought this would be easy stuff to do.. I am not familiar with icechat enviroment. triggers identifiers. etc.
The code will be a string of 6 characters.  They will be random numbers and letters format.. abc321 cba132 12c3ba  but the code will only be 6 characters and it will never be an actual word. Also it will not contain other characters such as hyphens, colons etc.

To make it more distinguishable such as placing a character before it so it is easier to recognize it.. such as "^^" .. then it would look like ^^abc123 or ^^c3a21b
There is no significance on the name of the file it is saved within.  But whatever the name is, it should be simple. infos.txt is fine.
 
Does that clear the air?
As far as the brownie points go, If it would not be too much to add.. I am thinking if you write to a file called infos.txt and the only thing saved in the file is a code such as "cba231" then when a second person posts.. then it would either append to that file, or it may replace the file.. just to eliminate confusion, It might be best to catalog it.  so if infos.txt exists, then infos01.txt is added to that directory.  It could be saved to C:\infos\infos  Once I have the foundation, I can customize it to fit in to my setup.. I really appreciate your help.  I will also treat this file as a tutorial of the commands I will be needing. This will be a big help.

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Direction for beginner scripting
« Reply #5 on: May 05, 2006, 11:43:31 AM »
So a user types in ^^abc123 , it will add "abc123" to the infos.txt file, and when another user types in another code, it will just keep adding it to the end of that infos.txt file, appending it, which is by far the simplest way to do it, instead of worrying about adding a new file for each new entry, which will end up giving you a lot of files with just 1 entry in it I thought it would be easier to just have 1 file with all the entries, at least thats what it seems to me. :)

This would be quite simple to do it this way.

I will whip up a script and post it here when its done.
The IceChat God

BrazilianGal

  • Newbie
  • *
  • Posts: 4
Re: Direction for beginner scripting
« Reply #6 on: May 05, 2006, 11:53:46 AM »
Good point, yeah appending is the way to go.  You got it!  You understand my problem yay Thank you thank you

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Direction for beginner scripting
« Reply #7 on: May 06, 2006, 08:49:01 PM »
Just paste this code into the Script Engine and save it, and away you go.
Its a fairly simple script, not too much code and pretty easy to figure out.
It is all VBScript using fso (FileSystemObject) to write/append the text file.

Code: [Select]

Dim fso, InfoFile, fsoFile
Set fso = CreateObject("Scripting.FileSystemObject")

'set the text file inside the Scripts Folder of the IceChatDir
InfoFile = GetIdentifier("$icechatdir") & "Scripts\infos.txt"

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

If Left(Message,2) = "^^" and Len(Message) = 8 Then
 'open the file for writing
 Set fsoFile = fso.OpenTextFile(InfoFile,8,True)

 'write the data out to the file
 fsoFile.WriteLine(Mid(Message,3))

 'close the file
 fsoFile.Close

End If

End Sub

The IceChat God