mIRC Bot Template

By vsTerminus on Dec 07, 2008

Want a mIRC based bot?
Can't seem to get started on your own?
Tired of trying to rip through the code for other peoples' bots?

Try this one!

I wrote this up today, it's designed for people to use as a starting point; a template. It provides basic structures for commands, pacing, logging, and more. Although it doesn't do anything useful as-is, it is not meant to be UsefulBot.mrc
So no, I won't be adding "useful" commands to it either. That's your job!

The main features of this bot are:

  1. Configurable trigger
    • So you're not forced to use ! for commands
  2. Command pacing for all commands
    • Prevents abuse
  3. Recognized Bot Owner, and Owner-Only commands
    • Want the power to make your bot talk, but not let anyone else do it to? Put it in the owner section!
  4. Access for commands is determined by channel status!
    • You can limit commands to be used by only Ops, or by anyone! Supports All, Voice, Halfop, Op, and Admin!
  5. Logging of all commands to a file
    • Want to see who's abusing your bot without reading through mIRC's logs? Here's everything people have used on your bot in one easy to read file.
  6. Comments and Descriptions for everything in the file
  7. Example commands for every user level

Installation:
Copy and paste the code below into a new text file.
Save it as BotTemplate.mrc into your mIRC folder
Open mIRC, and type
/load -rs "BotTemplate.mrc"

Note: You should NOT load this on the client you intend to chat from.
Note: You should be online on the same network as the bot when you load the script. If you do not, you will need to join the channel the bot is in AFTER the script is loaded, so that your host (IP) can be recorded by the bot.

Anyway, here's the code.

Enjoy!

mrc

; ==------------------------------------------------------------------------------------==
; Template for an IRC bot
; Written by vsTerminus
; This script is open source, and written for the purpose of modification by other users
; as both a learning tool, and a starting point for projects.
;
; This script may be freely distributed
; Under no circumstance should you profit from this or a modification of this script.
; The author hopes you will credit him somewhere in your code if you use it.
; ==------------------------------------------------------------------------------------==

; ==------------------------------------------------------------------------------------==
; Features of this template:
; 
; This template features a number of useful things in bot development
; Events are pre-written for LOAD, UNLOAD, CONNECT, and TEXT.
;
; This template will log all used commands by default to your logs folder. 
; Please ensure that it exists prior to using this script.
;
; The trigger for all commands is changeable
; Most bots use ! as a trigger. This is the default, but you may use anything.
;
; The bot will ignore commands from itself (Using !say !version will not work, for example)
;
; All commands are protected from abuse using a 5 second pace timer.
; You may modify this time.
;
; Aliases are provided for properly detecting a user's status in a channel
; Status levels supported are Voice (+), Halfop (%), Operator (@) and Admin (&)
; 
; You can configure a nick to use as the bot's owner. 
; You must be using this name when you join the channel for the bot to track your IP address properly.
; 
; Thanks for using this bot. Questions/Comments? E-mail me at vsTerminus@socialgamer.net
; ==------------------------------------------------------------------------------------==

on *:LOAD:{
        ; This section loads up the required variables
        ; Please look through it, as there are some things you can change
        ; that will affect how your bot operates.

        ; Version Info

                ; Name - Give your bot a name!
                ; This is NOT the bot's nickname. That is up to you to set.
                ; This is used in the bot's version info.
                ; Default = Bot Template
                %bot.name = Bot Template

                ; Author - Your name!
                ; Default = vsTerminus
                %bot.author = vsTerminus                

                ; Version - Set the bot version
                ; Default = Bot Template v1.0
                %bot.version = 1.0

        ; General Config

                ; Owner - You must set this to your nick.
                ; Default = vsTerminus
                %bot.owner = vsTerminus

                ; Trigger - You can set this to any character that you like
                ; EXCEPT letters of the alphabet. Anything else should be fine.
                ; Defatult = !
                %bot.trigger = !

        ; Miscellaneous

                ; Pacing timer - Limit commands so that they can be used
                ; a minimum of X seconds apart. Raise or lower this depending on
                ; What you like, and what feels natural.
                ; Default = 2
                %bot.pace = 2

        ; Logging
        ; You can enable/disable logging of used commands, and modify the file they are logged to here.

                ; Log commands used?
                ; Default = yes
                %bot.logCmds = yes

                ; Log file for commands, uses relative pathing.
                ; Default: logs/commands.log
                %bot.log = logs/commands.log

        ; Done with variables
        ; Please do not modify the lines below.

        ; This just primes the pacing. 
        %bot.nextAllowedCommand = $ctime

        ; This looks for the owner to be online, and stores their host (IP)
        if ( $address( %bot.owner , 2 ) != $null ) {
                %bot.owner.address = $address( %bot.owner , 2 )
        }

        ; Updates the log file
        if ( %bot.logCmds == yes ) {
                /write %bot.log ==------ Begin Session ( $+ $time $+ )------==
        }

        echo -a %bot.name %bot.version by %bot.author loaded successfully.
}

; ==------------------------------------------------------------------------------------==
; Aliases
; These are a few aliases that allow the bot to run correctly
; Please don't modify unless you know what you're doing.
; ==------------------------------------------------------------------------------------==

; This checks pacing
alias allowed {
        if ( $calc( $ctime - %bot.nextAllowedCommand ) >= 0 ) {
                %bot.nextAllowedCommand = $calc( $ctime + %bot.pace )
                return $true
        }
        else {
                return $false
        }
}

; Checks to see if the passed in name is an owner or not
alias owner {
        if ( $address( $1 , 2 ) == %bot.owner.address ) {
                return $true
        }
        else {
                return $false
        } 
}

; These aliases are used for detecting the user's channel status (Voice, Op, etc)
/prefixof {
  if ($1 == $null || $2 == $null) { return $null }
  var %pnick $nick($1,$2).pnick
  var %pos $pos(%pnick,$2,1)
  if (%pos == $null) return $null
  if (%pos == 1) return $null
  return $left(%pnick,$calc(%pos - 1))
}
/isvoice {
  if (+ isin $prefixof($1,$2) || $ishalfop($1,$2)) { return $true }
  return $false
}
/ishalfop {
  if (% isin $prefixof($1,$2) || $ischop($1,$2)) { return $true }
  return $false
}
/ischop {
  if (@ isin $prefixof($1,$2) || $isadmin($1,$2)) { return $true }
  return $false
}
/isadmin {
  if ($isowner($1,$2)) return $true
  if (& == $null) return $false
  if ($ircdadminchar(prefix) isin $prefixof($1,$2)) return $true
  return $false
}
/isowner {
  if ($ircdownerchar == $null) return $false
  if ($ircdownerchar(prefix) isin $prefixof($1,$2)) return $true
  return $false
}
/ircdownerchar {
  return $iif($1 == prefix,$iif(~ isin $prefix,~,@),q)
}
/ircdadminchar {
  return $iif($1 == prefix,$iif(& isin $prefix,&,@),a)
}

; ==------------------------------------------------------------------------------------==
; JOIN event
; This section is for any commands that you want to be executed when someone joins the chat
; For now, it just looks for the bot owner and tracks the host (IP)
; Useful things here are greetings. An example is provided.
; ==------------------------------------------------------------------------------------==
on *:JOIN:#:{
        if ( $nick == %bot.owner ) {
                %bot.owner.address = $address( $nick , 2 )
        }

        ; Uncomment the next line for channel greetings for all users!
        ; msg $chan - Welcome, $nick $+ !

        ; Or, if you just want to welcome voiced or higher users, uncomment the next section instead.
        ; if ( $isvoice( $chan , $nick ) ) {
        ;       msg $chan - Welcome, $nick $+ !
        ;}
}

; ==------------------------------------------------------------------------------------==
; Commands
; This is where the vast majority of your commands will go.
; This is also the section you should be editing most frequently.
; ==------------------------------------------------------------------------------------==

on 1:TEXT:*?trigger:#:{
        ; This handles displaying the current trigger for users.
        ; The ? may be substituted for any character.
        ; Pacing applies.

        if ( ( $allowed ) && ( trigger isin $1 ) ) {
                msg $chan - My current trigger is: %bot.trigger  
        }

}

on 1:TEXT:$( * $+ %bot.trigger $+ * ):#:{

        ; Welcome to the text command section
        ; This section is for commands such as !topic, which are issued in the channel
        ; A few example are provided for you, and the structure for you to add your own commands is explained

        ; Get the command the user issued
        ; Strip codes from the message first
        ; Then grab just the first word
        ; Then remove any instances of the trigger from the word.
        ; This leaves you with the command text only. 
        ; This is also why I suggest you to not use A-Z,a-z in your triggers.
        var %command = $replace( $gettok( $strip( $1- ) , 1 , 32 ) , %bot.trigger, $null )

        if ( $owner( $nick ) ) {
                ; This is where commands that are restricted for your use only go.
                ; These commands are NOT subject to pacing restrictions. 
                ; You may use them as often as you like

                ; If the bot does NOT recogize you as the owner, simple
                ; rejoin the channel, on the nick you specified as %bot.owner

                ; Example Provided: SAY - Make the bot say something
                if ( %command == say ) {
                        msg $chan $2-
                }

                ; Define more commands for yourself (The bot owner) here!

        }

        if ( $allowed ) {
                ; This section is for 'public' commands.
                ; These commands ARE subject to pacing, even for the bot owner.

                ; This section is broken up into several parts.
                ; One for each level of access: Regular User, Voiced User (+), Halfop (%), Full Op (@), and Admin (&)
                ; Please note that not all networks support all of these levels.
                ; WyldRyde, for example, does not use the Admin (&) symbol.

                ; Also note that users of higher status will also be able to use commands
                ; that are defined for lower status users.
                ; Example, Halfops will also be able to use commands in the Voice section
                ; and Full Ops can use commands in the Halfop section.

                ; First section: Voiced users
                if ( $isvoice( $chan , $nick ) ) {

                        ; Example Command: rules
                        if ( %command == rules ) {
                                msg $chan The rules are: Behave!
                        }

                        ; Define more commands for voiced users here!

                }

                ; Second section: Halfops
                if ( $ishalfop( $chan , $nick ) ) {

                        ; Example Command: MUTE - Mute the channel (mode +m)
                        if ( %command == mute ) {
                                if ( $2 == on ) {
                                        mode $chan +m
                                        msg $chan - Channel is now muted 
                                }
                                elseif ( $2 == off ) {
                                        mode $chan -m
                                        msg $chan - Channel is no longer muted
                                }
                                else {
                                        msg $chan - Please use %bot.trigger $+ mute on or %bot.trigger $+ mute off
                                }
                        }

                        ; Define more commands for halfops here!

                }

                ; Third section: Full ops
                if ( $ischop( $chan , $nick ) ) {

                        ; Example command: Kickban (or kb)
                        if ( ( %command == kb ) || ( %command == kickban ) ) {
                                mode $chan +b $address( $2 , 2 )
                                kick $chan $2 ( $+ $nick $+ ) $3-
                        }

                        ; Define more commands for full ops here!

                }

                ; Fourth section: Admins
                if ( $isadmin( $chan , $nick ) ) {

                        ; Example command: LEAVE - Make the bot leave the channel
                        if ( %command == leave ) {
                                part $chan Leaving the channel at request of $nick
                        }

                        ; Define more commands for admins here!

                }

                ; Final section: All users.
                ; No if statement here, commands places below apply to users of all status levels.

                ; Example Command: VERSION - Return the bot version
                if ( %command == version ) {
                        msg $chan - I am a %bot.name %bot.version by %bot.author
                }

                ; Example Command: HELP - Send the user a help file
                if ( %command == help ) {
                        msg $nick - My helpfile can be located at: mywebsite.com
                }

                ; Define more commands for regular users here!

        }
        ; Now all we have to do is log the command use
        ; This logs ALL command attempts, whether they are executed or not (due to pacing)
        ; This way you can identify people who are trying to spam the bot.
        if ( %bot.logCmds == yes ) { 
                /write %bot.log ( $+ $time $+ ) $chan $+ : < $+ $nick $+ > $strip( $1- )
        }
}

; ==------------------------------------------------------------------------------------==
; There are plenty of other events you could script into your bot
; Have a look at the mIRC help docs and use google. You'll find other stuff you can add.
; Perhaps in future versions of this template I'll provide example of more event types.
; ==------------------------------------------------------------------------------------==

on *:UNLOAD:{
        if ( %bot.logCmds == yes ) {
                /write %bot.log ==------ End Session ( $+ $time $+ )------==
        }
        echo -a %bot.name %bot.version by %bot.author unloaded successfully.
        /unset %bot.*
}

Comments

Sign in to comment.
PsyTrance   -  Aug 03, 2010

Woow man! I'm beginer in mIRC scripting, this is what i need. Thank You! :)

 Respond  
jibonanondodas   -  Aug 03, 2010

Lmao.. conpmana bro why did u send such a huge amount of money to an Online friend.. lol
(Chudir vai eida tui ki korli )

 Respond  
Spanky   -  Jan 07, 2009

WOWZERS

 Respond  
NIGathan   -  Jan 05, 2009

I rofl'd

 Respond  
^Neptune   -  Jan 04, 2009

The drama or the script? :P

 Respond  
ProjectDiesel07   -  Jan 04, 2009

I love it! Thanks

 Respond  
vsTerminus   -  Dec 10, 2008

Glad to know my script has become the home of a drama tale.

 Respond  
NIGathan   -  Dec 09, 2008

rofl, conpmana got conned.

 Respond  
conpmana   -  Dec 09, 2008

I am a sucker to the 10th degree and cost me $1,000 to figure that out so thank you terrycke.

Incase you missed that quote^^^^^ there it is again yes I am a %^$#ing dumb ass with a big heart and extra money to burn I guess;)

Tweetybird  -  Nov 04, 2020

Hi are you still looking for Terrick

Sign in to comment

KronicDreamer   -  Dec 09, 2008

wow how stupid of you to send someone money that you dont actually know! lmao
not his fault...

 Respond  
conpmana   -  Dec 09, 2008

Kasaba real name is TERRYCKE WRIGHT, I knew him from playing an online game called king of chaos, after playing the game with him for sometime you build a bond and I got to know him. About 1 year goes by and he starts to tell me how white people are being killed in South Africa and how he wanted to move to the United States, so I decided to help him. I had a job set up and a place for him to live, I was also going to pay for his plane ticket and give him start up money when he got here in the US. I felt really bad for him and what was happening there. He told me when applying for a travel VISA to come to the USA it would look better if he had money in his bank account and if the VISA didn’t got though he would send me my money back. I sent him $1,000.00 USD VIA Western Union which the fee to send the money was a few hundred dollars extra but he picked up $1,000 USD:
Money Transfer Control Number (MTCN):
2397125470

Date of Order:
10/15/2008

Amount Sent:
$1000.00

Receiver Name:
TERRYCKE WRIGHT

Status:
Picked Up

Well his VISA was denied and when I tried to get my money back he told me he was mugged on a train and lost all the money. Now he dont respond to my emails or PM's and I am a huge sucker for sending him that money:

thx Take care Richard ttyl, you have helped me make a dream come true here :) when i pick u up from the airport then we say that :) ummm that I will let you know... by even next week wednesday :) so talk to you then lol and at the airport :) Session Close: Wed Oct 15 18:39:20 2008 Session Start: Mon Oct 20 14:50:34 2008 Session Ident: Kasbah Session Ident: Kasbah (Casper@Cyanide-D7E7B23F.majic.org) hey conpmana hey is catchy on irc cathy nope not yet she should be home in 3 hours did you get my email ? when u send ohh a few days ago mate been trying to get you on IRC wanted to say thnak you very much and that I got the money The log on him saying he got stabbed is on my home computer but I just have to say don’t trust him and if you have dealing with him be on guard, because of him I wont ever help anyone I don’t really know again ever. I am a sucker to the 10th degree and cost me $1,000 to figure that out so thank you terrycke.
 Respond  
napa182   -  Dec 08, 2008

conpmana said:

Hey terrick since you dont reply to me VIA email or PM how about here, or shall I post what you did?

well out with it lol ;x what did they do?

 Respond  
conpmana   -  Dec 08, 2008

Hey terrick since you dont reply to me VIA email or PM how about here, or shall I post what you did?

 Respond  
newklear   -  Dec 08, 2008

Nice job vsTerminus :)
Great base for modification.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.