Using

Scripting

Testing your Scripts

So you have written a script that you call your own, and now you want to make sure that it works. Since you wrote it, in theory, you should know what it is suppose to do, but perhaps not when it is going to happen. Here, I will layout a few pointers to remember when testing your script.

1. XChat isn't all knowing

This one should be fairly obvious. Just remember that like any application, you need to speak XChat's language, not necessarily the other way around. XChat is doing exactly what it is told to do (normally) but you may think you are saying something else. Well, step back, and have a look, see if there is some scenario you didn't account for and test what would happen in that scenario.

2. You connection isn't a substitute for someone else

XChat handles messages coming from other people in a different manner than those coming from the client. For instance, if you /msg a channel, this will not be caught either by a PRIVMSG server hook or Channel Message print hook. It may be simplest to open another instance of XChat and connect to the same server as your main client. By using a clean profile, you won't introduce the problem of a script running twice.

3. Others don't want to see your tests

Most people don't want to be bothered with crap lines like "test" in a channel. It is therefor polite to test your scripts in a testing channel that you alone use. Some networks have a #test channel set up for this purpose, but it is easy enough to join a random channel you make up. Some people will test scripts in #{their_nickname}, but you can also create a random string of characters or prhase after the # sign. Perhaps #ILikeToTest, ai2f0yz, or #Blame_Canada_for_BlueCheese would be good for you.

4. Pretend to control the server

XChat has a nice command in /recv. With this command, you can "fake" messages being received from the server. This however does assume you know what the raw command would be. This would be good for testing certain hooks, or what the appearance of a message should be. Consider the following:

Receive a Channel Message
/recv :Spartacus!~italy@i.am.spartacus PRIVMSG #silarus :No I am Spartacus!
Devoice a user
/recv :AgentSmith!smith@neural-net.thematrix.net MODE #matrix -v Neo
Fake a quit
/recv :ChanServ!ChanServ@Services.Freenode.net QUIT :Ping timeout: 240 seconds
Wait 10 seconds and receive a private message
/timer 10 recv :luser!~dead@127.0.0.1 PRIVMSG mynick :Are you looking at XChat now?

If you want to see the raw format, simply open up Window -> Raw Log... and see what the messages are for different events.

5. Test your script in different circumstances

If you regularly have XChat minimized to the system tray, remember to test what happens when events happen in this state. Use your other connection to make sure you don't have unexpected behavior.

Summary

Scripting in XChat isn't rocket science, but it does help to think through how you plan to make sure your script does what you want it to. Other people may be able to help you debug it, but you are the author and truly know what you expect the script to do. Just don't get to stressed out in the process, it isn't worth getting an ulcer.



Print - Recent Changes - Search
Page last modified on December 03, 2008, at 05:20 PM