IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: TheCellist42 on March 27, 2008, 10:59:45 PM

Title: !status
Post by: TheCellist42 on March 27, 2008, 10:59:45 PM
Is there any way to make a status script to split up the topic? For example...

"The Topic Is: IRC Clients || ... || Visit Our Web Site (Topic || Status || Message)"

Is There Any Way To Have A Status Script That Only Would Change Part Of The Topic, Like... "!Status Is Sleeping" ?

"Ares Sets Topic To: IRC Clients || TheCellist42 Is Sleeping || Visit Our Web Site"

Any Way To Do Something Like This, Or Modify My Topic Script?   :-)

Topic Script:
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,7) = "!topic " and Len(Message) > 7 then
If ISOP(Nickname,Channel,ServerNumber)=True then
  NewTopic = Mid(Message,8)
  SendCommand "/topic Our topic is: " & NewTopic, ServerNumber
End If
End If
End Sub
Title: Re: !status
Post by: Morio on March 27, 2008, 11:47:44 PM
to get the current topic use: CurrentTopic = GetIndentifier("$chan(" & Channel & ").topic)

If the topic always has the same layout you can us something like this to parse it:

Code: [Select]
TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3

Title: Re: !status
Post by: TheCellist42 on March 28, 2008, 09:01:18 AM
I keep getting errors like "Unterminated string constant" and "Syntax Error"

I probably placed the line wrong
Title: Re: !status
Post by: Morio on March 28, 2008, 11:47:25 AM
Sorry, I seem to have missed a "

CurrentTopic = GetIndentifier("$chan(" & Channel & ").topic)"

Oh, and also the 4 other lines need an ) at the end
Title: Re: !status
Post by: Snerf on March 28, 2008, 12:07:35 PM
Still got it wrong Morio, the ending quote had to be inside the closing bracket, and also wise to add ServerNumber in there.

CurrentTopic = GetIndentifier("$chan(" & Channel & ").topic", ServerNumber)
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 11:38:44 AM
Where Would I Put The Line?...(Replacing !topic with !status)  :?

I Can't Get It To Work
Title: Re: !status
Post by: Morio on March 29, 2008, 11:45:31 AM
You can't use the ONTEXT sub for this because it won't trigger for yourself. You could use something like this

Code: [Select]
Sub NewStatus(StatusChange)
Your code here
End Sub

then make an alias like this:
Code: [Select]
/status:/! NewStatus $1-

then you can just use /status newstatus_goes_here to change the status part
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 11:54:23 AM
I wouldn't be using the script myself, my bot would, so I could trigger it
Title: Re: !status
Post by: Morio on March 29, 2008, 01:03:31 PM
Then you would use the !status command just like you use the !topic command
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 01:31:03 PM
The Problem, Is That I Can't Get It To Work

How Would I Put The Line Into The Script?
I Tried, Didn't Get Any Errors, But It Didn't Work Either
Title: Re: !status
Post by: Morio on March 29, 2008, 02:15:27 PM
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
.
.
.
End Sub
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 02:42:42 PM
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
If ISOP(Nickname,Channel,ServerNumber)=True then
NewTopic = Mid(Message,9)
CurrentTopic = GetIdentifier("$chan(" & channel & ").topic)"
SendCommand "/topic " Sam Is " & NewStatus, ServerNumber
End If
End If
End Sub

??
Title: Re: !status
Post by: Morio on March 29, 2008, 02:51:13 PM
So you decided to completely skip the other 4 lines I posted earlier? The code that actually parses the topic.

Code: [Select]
TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)

TopicLeft is the stuff before the first '||', TopicMiddle is the stuff between the '||' and TopicRight is the part after the last '||'
This way you can pretty easily change any part of the topic. and to set the new topic do this:

Code: [Select]
SendCommand "/topic " & Channel & " " & TopicLeft & " || " & TopicMiddle & " || " & TopicRight,ServerNumber
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 02:58:45 PM
Im Still Getting Expected End Of Statement Errors

And I Tried To Fix It, But It Still Wouldn't Work!
Title: Re: !status
Post by: Morio on March 29, 2008, 03:56:05 PM
Check the console and see which line gives the error.

None of the lines in my last post gave any sort of error.
Title: Re: !status
Post by: TheCellist42 on March 29, 2008, 04:04:15 PM
Is The Script laid Out Correctly, What Did I Do Wrong?

Also, What Line Can I Put In My Topic Script To Make It Change The First Part Of The Script Only?
Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 12:57:23 AM
Here IS The Script, Its Probably Wrong:

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
If ISOP(Nickname,Channel,ServerNumber)=True then
NewTopic = Mid(Message,9)
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
SendCommand "/topic " & Channel & " " TopicLeft & " || " TopicMiddle " || " & TopicRight,ServerNumber
End If
End If
End Sub

And This Is The Error I Get:
[02:56] -- Script Engine Error:1025:Expected end of statement: Line #9 --SendCommand "/topic " & Channel & " " TopicLeft & " || " TopicMiddle " || " & TopicRight,ServerNumber

What Did I Mess Up?
Title: Re: !status
Post by: DarkStar on March 30, 2008, 01:06:43 AM
Remember; for every ( there is a ). :D the problem was on lines 5 and 6. Heres the fix:


Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
If ISOP(Nickname,Channel,ServerNumber)=True then
NewTopic = Mid(Message,9)
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3))
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2))
SendCommand "/topic " & Channel & " " TopicLeft & " || " TopicMiddle " || " & TopicRight,ServerNumber
End If
End If
End Sub
Title: Re: !status
Post by: Morio on March 30, 2008, 02:00:29 AM
TheCellist42: You can't just leave out lines from the code. First of all, it won't parse the topic properly, and second, you haven't set any value for the TopicRight variable, but you are still using it.

Code: [Select]
TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)

You need all of those lines

and also you should have just copied the sendcommand line I pasted. The 'Expected end of statement' means that there's a '&' missing from your code.

Code: [Select]
SendCommand "/topic " & Channel & " " & TopicLeft & " || " & TopicMiddle & " || " & TopicRight,ServerNumber
Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 11:20:56 AM
Still Nothing, I Did Everything Morio Suggested, I Tried DarkStar's Script, And Nothing Worked  :?
Title: Re: !status
Post by: Morio on March 30, 2008, 11:42:56 AM
just a small typo in this line:
Code: [Select]
CurrentTopic = GetIdentifier("$chan(" & Channel & ").topic", ServerNumber)This time I tested it myself, and it works
Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 11:50:42 AM
Well, I Replaced The Old Line With The New One And I Got No Errors, But It Didn't Change The Topic To What I Wanted

ex. Our topic is: Linksys Routers || Sam Is Sleeping || my website here

I Type "!Status Sam Is Here" and nothing happens, where as I would like for the bot to change the whole topic too...

Our topic is: Linksys Routers || Sam Is Here || my website here

Any Ideas What Has Gone Wrong?

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
If ISOP(Nickname,Channel,ServerNumber)=True then
NewTopic = Mid(Message,9)
TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
CurrentTopic = GetIdentifier("$chan(" & Channel & ").topic", ServerNumber)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
SendCommand "/topic " & Channel & " " & TopicLeft & " || " & TopicMiddle & " || " & TopicRight,ServerNumber
End If
End If
End Sub
Title: Re: !status
Post by: Morio on March 30, 2008, 11:56:53 AM
the four lines I posted only separate the different parts of the topic, they only contain the information about the current topic. On your SendCommand line, replace TopicMiddle with NewTopic
Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 12:30:35 PM
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Left(Message,8) = "!status " and Len(Message) > 8 then
If ISOP(Nickname,Channel,ServerNumber)=True then
NewTopic = Mid(Message,9)
TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
CurrentTopic = GetIdentifier("$chan(" & Channel & ").topic", ServerNumber)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
SendCommand "/topic " & Channel & " " & TopicLeft & " || " & "NewTopic" & " || " & TopicRight,ServerNumber
End If
End If
End Sub


I Don't Know If This Is Correct Or Incorrect But It Isn't Working  :cry:

Also, I Don't Know If It Was Correct  To Put Quotations Around NewTopic, But Without Them I Got An Invalid Procedure Call Error
Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 12:33:33 PM
Never Mind I Got Invalid Procedure Call Anyway, I Was Reading The Error From The wrong Line
Title: Re: !status
Post by: Morio on March 30, 2008, 12:38:40 PM
Do you even read what I post.

YOU CAN'T LEAVE OUT *ANY* OF THE LINES I POSTED.

Code: [Select]
CurrentTopic = GetIdentifier("$chan(" & Channel & ").topic", ServerNumber)

TopicLeft = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
CurrentTopic = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)
TopicMiddle = Left(CurrentTopic,InStr(CurrentTopic,"||") - 2)
TopicRight = Mid(CurrentTopic,InStr(CurrentTopic,"||") +3)

Title: Re: !status
Post by: TheCellist42 on March 30, 2008, 12:50:33 PM
Yes I Read What You Posted, I Just Confused It With Something Else And Replaced The CurrentTopic Line With The New One, Sorry, It Works Now.