5 Replies - 11659 Views - Last Post: 02 January 2011 - 12:02 AM

#1 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10364
  • View blog
  • Posts: 38,373
  • Joined: 27-December 08

Week #39- mIRC

Post icon  Posted 21 November 2010 - 08:57 AM

This week's challenge is mIRC Scripting. Thanks Martyr2 for creating this challenge!

Challenge: Work with the new mIRC 7.15 and use its scripting engine to create an HTML web server script.

mIRC is by far one of the most popular IRC chat clients on the planet. With millions of downloads and hundreds of thousands of "scripters" world-wide it is a great application for chatting with friends, sharing files with them and participating on multiple networks from around the world. I personally have used it for over 13 years.

Using mIRC's uber cool scripting engine, scripters can easily build utility scripts for doing everything from simple "Hello World" scripts to advanced scripts with networking features, binary data manipulation, file handling or even executing dlls written in other languages.

Your challenge is to download the mIRC chat program from the mIRC Download link, install and connect to a network. Then from the "Scripts editor" (fifth icon from the left on the toolbar) code up a basic web server for serving static HTML content. You can test it by opening up a browser and trying to fetch documents using your loopback IP address (127.0.0.1) or your internal network IP. To allow others to access it, make sure you configure your firewalls to let requests through and that they can access your IP from the outside.

To get you started learning the language, try selecting the mIRC .chm file that comes with the program's exe. In there you will find a comprehensive list of commands, events and functions they call "aliases". You will find mIRC: Help Resources also very useful for learning various program features and general Internet information that you can use with your scripts. At www.mirc.com you will also find a helpful community of scripters who have been playing with the language for years (some even over a decade).

To show you how easy it is, try entering the following alias into your scripts editor under the "Remote tab"...

alias hello.world {
   echo -a Hello World!
}



Then in any mIRC window type /hello.world to see your "Hello World!" message appear on screen.


Other types of scripts you can experiment with and make are:

* Away script which lets other chatters know you are away, will accept messages and logs them, then lets you return showing how long you have been gone.
* A script they refer to as a "Talker" which allows you to write in rainbow colors, highlight nicknames etc.
* The ever popular Mp3 Player which allows you to play music files on your computer and tells others what music you are playing.
* Operator tools for making channel management easier and kicking or banning trouble makers
* ASCII art player for showing ASCII made art in the channel for others to see
* A channel bot for maintaining your channel, welcoming users or even serving them fantasy drinks through the channel.
* A script which reads the weather for people who type out their area code and echos the content into the channel or privately.
* An RSS reader which reads subscription news to channels you are on.


Resources:

* mIRC Homepage
* mIRC.net which has tutorials and scripts
* mircscripts.org (Great place to find the latest in scripts)
* mIRC Scripting Help Forum


How To Get Started:

Download the program from mIRC.com - Download Page, install it and join any of the IRC networks listed in the program or join friends on their IRC networks. You can find some people from DIC on the irc.geekshed.net network in #dreamincode. But once you install the program, you have full access to the scripting features and don't have to have any extra libraries or anything. You are not limited to making chat related scripts either. You can make all sorts of utilities with dialogs, windows, pictures, graphics, music and more. It is also a great way to get into programming and teach you some of the basics which are related to all sorts of programming languages.

An example script will be provided by me soon after the challenge has been posted for awhile. If I haven't posted something within 2 weeks after this post is "Officially posted" then just ask me. I already have the example coded and I can simply post it. Post your scripts/scriptlets for the world to see!

Thanks!

Martyr2 (DIC Mentor)

Is This A Good Question/Topic? 0
  • +

Replies To: Week #39- mIRC

#2 laserbeak43  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 134
  • Joined: 07-November 09

Re: Week #39- mIRC

Posted 21 November 2010 - 10:27 AM

I got all excited, but they force you to pay for mirc now. I simply don't have the money for it at the moment.
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,085
  • Joined: 18-April 07

Re: Week #39- mIRC

Posted 21 November 2010 - 11:39 AM

No, they don't force you to pay for it. When you first start you will see a dialog that asks you to register if you like it. Just wait a few seconds and the continue button will become enabled. Click it and you can use the program with all features enabled and fully working.

mIRC has always been a shareware program, but Khaled (the creator) has always kept it fully functional no matter whether you register it or not. Registration is also pretty cheap and will last you for life.

But again, just wait a second for the continue button to become enabled. Then you can use it as if you paid for it. :)

P.S. Believe me, I have used it for over 13 years and never paid for it.

This post has been edited by Martyr2: 21 November 2010 - 11:41 AM

Was This Post Helpful? 2
  • +
  • -

#4 laserbeak43  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 134
  • Joined: 07-November 09

Re: Week #39- mIRC

Posted 21 November 2010 - 03:00 PM

yeah my copy won't let me play after i hit continue. oh gosh nvm. it works now. 10+ years here, but that doesn't mean i can't act like a noob now and then :P
Was This Post Helpful? 0
  • +
  • -

#5 SmaJLe  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 21
  • Joined: 06-November 07

Re: Week #39- mIRC

Posted 23 November 2010 - 12:38 AM

Woha... I haven't done mirc scripting for years =)
Sounds like fun ^_^
Was This Post Helpful? 0
  • +
  • -

#6 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,085
  • Joined: 18-April 07

Re: Week #39- mIRC

Posted 02 January 2011 - 12:00 AM

No one ever asked for it, but here is an example as promised for the challenge...

; Listen on port 1111
alias html.listen { socklisten html 1111 }


; Listen for incoming html page requests
on *:socklisten:html: {
  echo -a Someone requested a homepage
  sockaccept html2
}

; Read from the html socket, parse the request and send a response
on *:sockread:html2:{
  if ($sockerr > 0) return

  sockread %temp

  ; Read through the request.
  ; Here we can look for key data
  while (%temp != $null) {
    sockread %temp
  }

  request.homepage $sockname
}

alias -l request.homepage {
  if ($$1) {
    ; Write to the socket a homepage response.
    sockwrite -tn $1 HTTP/1.1 200 OK
    sockwrite -tn $1 Date: $gmt($ctime, ddd dd mmm yyyy hh:nn:ss)
    sockwrite -tn $1 Vary: Accept-Encoding
    sockwrite -tn $1 Connection: close
    sockwrite -tn $1 Content-Type: text/html; charset=iso-8859-1
    sockwrite -n $1 
    sockwrite -tn $1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    sockwrite -tn $1 <html><head>
    sockwrite -tn $1 <title>Success!</title>
    sockwrite -tn $1 </head><body>
    sockwrite -tn $1 <h1>Success!</h1>
    sockwrite -tn $1 <p>You successfully requested the home page!<br />
    sockwrite -tn $1 </p>
    sockwrite -tn $1 <hr>
    sockwrite -tn $1 <address>mIRC Web Server Port 1111</address>
    sockwrite -tn $1 </body></html>
    sockwrite -t $1 $crlf $+ $crlf 

    ; After script is done, close the socket.
    .timerclosesock 1 0 sockclose $1
  }
}




Then of course you can request the page locally using your loopback address on port 1111 (point your browser to http://127.0.0.1:1111, but after you first activate listening using /html.listen. Then it will return a basic web page to your browser. Of course you can build onto this to do all sorts of things.

Enjoy! :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1