Author Topic: I have no programming background and was trying to do a basic script...  (Read 3024 times)

Anubis85

  • Guest
Basically, I wanted a PM to let me know when this person signed into a channel.  I wanted a PM b/c if I'm afk I might not see a notice.  First question: for the first ONJOIN, do I need to specify the channel?  I put that there because I am in multiple channels and wanted to make sure that at minimum it worked there.  Will it work globally if I remove that?  Will it work if he signs into a channel that I'm in but not currently?

I had it working at one point, but then added the ONNICK, and the second ONJOIN because he had a couple names.  Should I just pick one and go with that or are all three ok? 

On an unrelated note, how do I write it to do more than one thing? For example, if I wanted it to send me a PM and send a notice or PM to other chanops, how would I write that?  Thanks!

Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
if lcase(Nickname)="wewt" or lcase(Nickname)="wewt2" and lcase(Channel)="#mychannel" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
End If 
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if lcase(NewNick)="wewt" or lcase(NewNick)="wewt2" then
  SendCommand "/msg my nick " & "wewt is on IRC ", ServerNumber
End If
End Sub

Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
if Host="*@something.something.net" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
End If
End Sub

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Yes, if you remove the checking for a channel, it will work on all channels, on ALL servers you are connected to.

You can only have 1 ONJOIN  or ONNICK in a single script. 1 of each that is. So you have 2 ONJOIN's and 1 ONNICK, the 2nd ONJOIN will not work.

If you wish to have multiples, they will need to be seperated into different files.

OR:

You combine them into 1 ONJOIN subroutine.

Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
if lcase(Nickname)="wewt" or lcase(Nickname)="wewt2" and lcase(Channel)="#mychannel" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
End If
if Host="*@something.something.net" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
End If
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if lcase(NewNick)="wewt" or lcase(NewNick)="wewt2" then
  SendCommand "/msg my nick " & "wewt is on IRC ", ServerNumber
End If
End Sub


Also, there is 1 small flaw with your commands.
SendCommand "/msg my nick " & "wewt is on IRC "

the word "wewt" should have a space before it, or it will combine  your nickname and the word 'wewt' together.

So like this:
SendCommand "/msg my nick " & " wewt is on IRC "

If you wish to send multiple commands, just send another SendCommand.

Code: [Select]
if blah blah then
  SendCommand "/command 1", ServerNumber
  SendCommand "/command 2", ServerNumber
end if
The IceChat God

Anubis85

  • Guest
Thanks!  I combined the host with the ONJOIN like you said but haven't had a chance to test it out yet.  If the nickname matches and the host matches as well, will that send me two messages or will it just run one of them?

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
It will send 2 messages.

If you want it to check for 1 OR the other, use 'else if' between.

Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
if lcase(Nickname)="wewt" or lcase(Nickname)="wewt2" and lcase(Channel)="#mychannel" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
else if Host="*@something.something.net" then
  SendCommand "/msg my nick " & "wewt is on IRC ",ServerNumber
End If
End Sub

Also, the host wont match a wild card like that, you will need to check for an exact host, or use some regex or such to match a wild card.
The IceChat God

Anubis85

  • Guest
I guess the wildcard was too hopeful.  Can you also help me with this:

Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
if Nickname="Guest" and Channel="#test" then
  SendCommand "/say " & Nickname & " 4if you want to change you nick type /nick and your new nick. For example: ",ServerNumber
  SendCommand "/say " & " 4/nick Naruto ",ServerNumber
End If
End Sub

The Channel="#test" means that if guest entered another channel it wouldn't run the script right? 
How do I get it so if I am not actively in #test it replies only in #test and not the one I am in when it happens?

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Well, /say always says something in the current window you are in. You use /msg #channel to message to a specific channel.
The IceChat God

Anubis85

  • Guest
Thanks a lot for your help.  One last question... Is there a way I can run a script that can check to see if an incoming connection is from a proxy server?

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Not really, you can only check that at server level.
The IceChat God