mIRC Home    About    Download    Register    News    Help

Print Thread
#254140 23/07/15 11:23 PM
Joined: Jul 2015
Posts: 4
F
FPG Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Jul 2015
Posts: 4
Hello mIRC help forums.

I've used IRC, particularly mIRC a fair amount over the years, but never had occasion to write some scripts before. Our channel occasionally uses spoilers and we are used to using rot13 elsewhere so I jumped in and started tinkering to get a remote function to encode and decode our spoilers safely.

This is what I have at the moment.

Code:
ctcp 1:encode*:/say #MarkSpoils $nick $iif($isid,return,msg #) $regsubex($1-,/([a-z])/gi,$chr($calc($asc(\1) $iif($asc($upper(\1)) < 78,+,-) 13)))
ctcp 1:decode*:/notice $nick $iif($isid,return,msg #) $regsubex($1-,/([a-z])/gi,$chr($calc($asc(\1) $iif($asc($upper(\1)) < 78,+,-) 13)))


It functions, but could be a bit nicer. Some of the things I'd like to help with:
  • Currently each message from rot13 starts with "msg rapbqr" or "msg qrpbqr". Is there a way to prevent this?
  • The encode option needs to go into the main chat and list who said it. My current solution works but I'd guess could be better.
  • The decode option ideally needs to go into the main chat but only seen by whoever requested it. Again, it does this right now but is there a better way?
  • The commands to encode and decode need to be kept simple, if possible. "/ctcp rot13 (encode/decode)" isn't bad, as most clients can have an Alias in there to shorten it, but if it can be cut down all the better.
  • Something really cool would be the ability to only encode/decode certain parts of your message, but this is wish-list stuff now.


I'll appreciate any help you can give me. I'm learning as I go for this, so my apologies if I've made any faux pas. The list is in descending order of what is most needed.

Many thanks, FPG.

Edit: A few things I forgot, might be helpful.
  • mIRC version: v7.42
  • We will probably want to add more varied functions to the remote script in the future, but for now this is all we need.

Last edited by FPG; 24/07/15 01:54 AM.
Joined: Jul 2015
Posts: 4
F
FPG Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Jul 2015
Posts: 4
I can't seem to find the edit function now, can we only do one post edit here? Is it because I'm a new user and the number of edits I can do will increase as I post? (Otherwise apologies for the double post.)

Onto the matter at hand. I know there's not a specific problem I'm asking for help with here (apart from point 1, removing the excess text for encode/decode requests). If I can get direct help, that'd obviously be great, but I'm happy to do the legwork myself (and am continuing to do so, not as a matter of impatience, but because I can't stop wanting to tinker with it).

If you can point me to some solid resources that are more out of the way than some basic google searches or suggest the theory behind why something I've done isn't working/won't work/could be better that'd be more than enough.

I've altered my script to include some new functions; the first two, while simple, I wrote myself, so I feel I'm learning a bit here and there. They include a join message, a way to list current channel specific commands and a dice function (which I plan to play around with myself, I want to customise the entry and export but that seems simple enough).

Code:
on 1:JOIN:#MarkSpoils:/notice $nick For channel commands type (without the quotes) "/ctcp rot13 chancomm"
ctcp 1:chancomm:/notice $nick The channel commands are... | /notice $nick Channel Commands "/ctcp rot13 chancomm" | /notice $nick Encoding "/ctcp rot13 encode" | /notice $nick Decoding "/ctcp rot13 decode" | /notice $nick Dice Rolling "!dice <number of dice> <number of sides>"
ctcp 1:encode*:/say #MarkSpoils $nick $iif($isid,return,msg #) $regsubex($1-,/([a-z])/gi,$chr($calc($asc(\1) $iif($asc($upper(\1)) < 78,+,-) 13)))
ctcp 1:decode*:/notice $nick $iif($isid,return,msg #) $regsubex($1-,/([a-z])/gi,$chr($calc($asc(\1) $iif($asc($upper(\1)) < 78,+,-) 13)))
on $*:TEXT:/^!dice (10|[1-9]) (\d+[0-9]|[1-9])$/:#: var %i = 0, %limit = $iif($2 > 10, 10, $2) | while %i < %limit { inc %i | .timer 1 $calc(%i * 2) msg $chan $nick rolled $3 $+ -sided die number %i of $2 $+ : Result $rand(1,$3) }


I've noticed many other threads have their scripts in many lines, not single ones like mine? Is that preferred on here and/or in mIRC scripting itself? The rot13 and dice scripts I found were single line naturally.

Edit: New actual problem I hope to fix myself - Changed the order of the scripts (to the above) and now encode and chancomm no longer work. Wiping Remote and adding them back in separately or on their own doesn't help either.

Edit 2: chancomm is back, typos on my script. encode is still not working, I'm getting a * You are not on a channel message when encode attempts are made. I think I had this problem very early on but I thought I solved it already.

Last edited by FPG; 24/07/15 08:23 AM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
$iif($isid,return,msg #) is meant to function in an alias - as an identifier or command to be called from a channel event.

"rapbqr" and "qrpbqr" appear because you're encoding the "encode" and "decode" text in $1-, use $2- instead.

Quote:
The decode option ideally needs to go into the main chat but only seen by whoever requested it. Again, it does this right now but is there a better way?

I don't know what you mean by this. You either send it to the channel or you send it to the user. You can't send it to the channel to be seen by only the user.

Your encode response was not working because you can't use /say in a remote event.

Code:
alias rot13 { return $regsubex($1-,/([a-z])/gi,$chr($calc($asc(\1) $iif($asc($upper(\1)) < 78,+,-) 13))) }

ctcp 1:encode *:?:msg #MarkSpoils $nick $+ : $rot13($$2-) }
ctcp 1:decode *:?:notice $nick $rot13($$2-)


Editing a post is only available for a limited period of time after the post is first made. And aside from very short lines or logically grouping commands it's preferable to break your script into multiple lines.

Last edited by Loki12583; 24/07/15 03:31 PM.
Joined: Jul 2015
Posts: 4
F
FPG Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Jul 2015
Posts: 4
Thanks for the help.

Quote:
Your encode response was not working because you can't use /say in a remote event.


I finally figured out to replace say with /msg not long before your reply after much head scratching. I accidentally may have changed it somehow, but everywhere I had back-ups it used /say and it functioned for a day like that? I concede it's probable I discovered I must use /msg, didn't document that anywhere but the .ini, overrode that with the outdated code and then forgot about the solution.

Quote:
Quote:
The decode option ideally needs to go into the main chat but only seen by whoever requested it. Again, it does this right now but is there a better way?


I don't know what you mean by this. You either send it to the channel or you send it to the user. You can't send it to the channel to be seen by only the user.


My apologies, I don't think I explained myself very well here. What I meant was, I'd ideally like a command sent to the remote script that would post the output as a notice to the person in the channel who requested it. As a first pass I used /query instead of /notice, for comparison. It works as I want it to how it is right now (excluding the aforementioned extra stuff always being sent).

Quote:
Editing a post is only available for a limited period of time after the post is first made. And aside from very short lines or logically grouping commands it's preferable to break your script into multiple lines.


So noted, I've been looking around and writing some basic scripts to practice writing the script on multiple lines.

---

I'm a little unsure on how to implement the help you provided regarding the encode and decode commands, as well as the code you posted. I don't really understand the rot13 script I found, I just know it works. I copied the first line of your code into Aliases and the third and fourth into Remote (my logic being, alias goes in Aliases, ctcp goes in Remote). However, when I try to encode text I get:

Quote:
[16:40] <rot13> FPG:


and it's just blank after that. Decode returns nothing. rot13 logs both actions in the server window (can't think of the proper name off the top of my head) like such:

Quote:
[16:40] [FPG encode] This is a test
-
[16:53] [FPG decode] blahblahblah

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Everything I posted goes in remotes

Joined: Jul 2015
Posts: 4
F
FPG Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Jul 2015
Posts: 4
Encode is working exactly as we want it and is beautiful, but decode is still not sending any decrypted spoilers?

I copy+pasted your script into remotes as instructed, and to double check unloaded every other remote script and tried just your code and still no luck. Again, they are being seen by the script like before, but there's no output.


Link Copied to Clipboard