mIRC Home    About    Download    Register    News    Help

Print Thread
How to create a Bot (simple commands) #236064 02/02/12 02:28 AM
Joined: Feb 2012
Posts: 13
G
Gasioulis Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Feb 2012
Posts: 13
Hello guys. I am new in here so let me introduce a bit. I am Kostas and i am 20 years old. I have some questions over mirc (started using it 1 year ago).

So i have created a channel and i want to make a simple bot for it. Not something complicated, just to create a bot for it with simple commands like it can say (Hello and welcome to #channel).

If anyone can help i would REALLY appreciate this.

Thanks in advance,

Kostas.

Re: How to create a Bot (simple commands) [Re: Gasioulis] #236065 02/02/12 02:37 AM
Joined: Feb 2012
Posts: 4
S
Spoofing Offline
Self-satisified door
Offline
Self-satisified door
S
Joined: Feb 2012
Posts: 4
First, use command: /set %channel #yourchannel, then press Alt + R and put in Remote:

Code:
on !*:JOIN:%channel:notice $nick Welcome to $chan $+ , $nick $+ ! Type !help for more...
on *:TEXT:!help:%channel:notice $nick Oh, hai! I am Kostas and i am 20 years old.

Re: How to create a Bot (simple commands) [Re: Spoofing] #236066 02/02/12 03:33 AM
Joined: Feb 2012
Posts: 13
G
Gasioulis Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Feb 2012
Posts: 13
Thanks a lot dude, that helped me a lot. But seems i am gonna bother you more (the lust for learning :P). Now i wanna know how i can setup a BOT like i will login a bot named Mychannel-BOT and when i type some commands like !next, or !add, or !teams etc it will spam me like this script you made..

Secondly, is it possible to edit further this scipt (like clickin !next and typing sth else?). Or it's a 2 line script!? And if yes how i can make more scripts!? Thanks in advance

(i begin to love these forums!!).

Best regards,

Kostas


[EDITING]Basically to explain you what i need is that:
I am playing cs 1.6 gather. Means i login to mirc, i /j #gatherchannel and there's a bot for example @Gatherchannel-Bot. And so i can use some commands to !add myself in game. When it's -M i can type !add and so the bot adds me in the lineup (5v5). When i click !remove it removes me from that. When i type !teams it shows me the teams and the slots. And when the teams get filled it gives +M, sends pass (IP from the server we gonna play) to every player and after it gives -M again. Moreover moderators can use !ban NICK REASON and ban someone for a certain amount of time etc. I need a BOT doin not these commands (not making a gather channel) but something similar to this. A bot that when you type !something at channel it will spam in that way.[EDITING]

Last edited by Gasioulis; 02/02/12 04:48 AM.
Re: How to create a Bot (simple commands) [Re: Gasioulis] #236070 02/02/12 10:52 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You asking for a big script, will take time for someone to write it, try google for a addon that do what you like, a good place to start is www.mircscripts.org , and then go to the addons section.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: How to create a Bot (simple commands) [Re: Gasioulis] #236072 02/02/12 01:04 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There are a variety of bots already written that will do all kinds of things. You will be best off checking script sites like the one given above to see what is available and figure out exactly what you need. In most cases, there will already be something written for you.

As far as learning to script, the help file is a great resource. Start with a simple script, such as using on TEXT to respond to certain triggers...

Code:
on *:text:some trigger:#channel: {
  echo -a I am echoing something...
  msg $chan I am saying somthing in the channel...
  describe $chan I am using /me in the channel...
  msg $nick I am sending a message to the person who typed the trigger...
}


And so on. This is the base for any bot script. Use /help on text for syntax and other information. From there, just expand outward. Again, you'll want to start small and work up to something big; not the other way around.


Invision Support
#Invision on irc.irchighway.net
Re: How to create a Bot (simple commands) [Re: Riamus2] #236080 03/02/12 02:05 AM
Joined: Feb 2012
Posts: 13
G
Gasioulis Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Feb 2012
Posts: 13
I found out this http://www.hawkee.com/snippet/3749/ and i started using it. I did launched another bot first and it worked. But i am trying to launch this with /load -rs bot.mrc and all comes up is: * Loaded script 'C:\Program Files\mIRC\Bot.mrc'

But it doesn't load nor can press the commands like !setmenext etc.

I created 1 more channel (as a prive channel for admins to launch games). So i have #mychannel and #mychannel.admins . I logged bot in both channels and gave it a 9999 access but when i load the bot.mrc and press /set %channel #mychannel and /set %prive %mychannel.admins as i said i can't use any commands so it doesn't work till now. Any help on it!?!

Last edited by Gasioulis; 03/02/12 03:55 AM.
Re: How to create a Bot (simple commands) [Re: Gasioulis] #236082 03/02/12 08:00 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You should ask in that "forum"-- it seems other users have the same issue-- and some are saying it doesn't work at all.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: How to create a Bot (simple commands) [Re: argv0] #236083 03/02/12 08:55 AM
Joined: Feb 2012
Posts: 13
G
Gasioulis Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Feb 2012
Posts: 13
Nah i found a better version of that script and it seems to work quite better only with a few mistakes. But i wanna ask YOU guys cause i kinda begin to love these forums and they seem really helpfull with people that can really provide helpfull answers! I will post the script and if anyone is willing to help me with some things that i needa change/fix is welcomed smile

Code:
on *:TEXT:!add:%channel:{
  if (%add == enable) {
    add
  }
}

on *:TEXT:!addme:%channel:{
  if (%add == enable) {
    add
  }
}


on *:TEXT:!add*a:%channel:{
  if (%add == enable) {
    checkteamsa
  }
}

on *:TEXT:!addme*a:%channel:{
  if (%add == enable) {
    checkteamsa
  }
}

on *:TEXT:!add*b:%channel:{
  if (%add == enable) {
    checkteamsb
  }
}

on *:TEXT:!addme*b:%channel:{
  if (%add == enable) {
    checkteamsb
  }
}

on *:TEXT:!remove:%channel:{ .msgremove }

on *:TEXT:!removeplayer*:%channel:{ if ($nick == %admin) && ($2 isincs %teama) { .set %teama $reptok(%teama,$2,?,1,32) | .dec %slots | .dec %slots1 | teams }
  elseif ($nick == %admin) && ($2 isincs %teamb) { .set %teamb $reptok(%teamb,$2,?,1,32) | .dec %slots | .dec %slots2 | teams }
}


on *:TEXT:!teams:%channel:{
  if (%add == enable) { teams }
  else { .notice $nick ***GatherServicesBot***: There is no gather in progress. }
}

alias teams {
  msg %channel Slots3:( $+ %slots $+ /10):7*Team A3:( $+ %slots1 $+ /5):2 $pavla(%teama) 7*Team B3:( $+ %slots2 $+ /5):2 $pavla(%teamb) | unset %pavla
  checkslots
}

alias add {
  if (($nick !isincs %teama) && ($nick !isincs %teamb)) { testslots }
  else { .notice $nick ***GatherServicesBot***: You are already added. }
}

alias testslots {
  if (%slots1 > %slots2) { add-b }
  else { add-a }
}

alias add-a {
  if (%slots1 != 5) {
    .set %teama $reptok(%teama,?,$nick,1,32)
    .inc %slots
    .inc %slots1
    .teams
  }
}

alias add-b {
  if (%slots2 != 5) {
    .set %teamb $reptok(%teamb,?,$nick,1,32)
    .inc %slots
    .inc %slots2
    .teams
  }
}

alias checkteamsa {
  if (($nick !isincs %teama) && ($nick !isincs %teamb)) { add-a }
  else { .nickremove | add-a }
}

alias checkteamsb {
  if (($nick !isincs %teama) && ($nick !isincs %teamb)) { add-b }
  else { .nickremove | add-b }
}

alias nickremove {
  if ($nick isincs %teama) { .set %teama $instok($remtok(%teama,$nick,1,32),?,5,32) | .dec %slots | .dec %slots1 }
  elseif ($nick isincs %teamb) { .set %teamb $instok($remtok(%teamb,$nick,1,32),?,5,32) | .dec %slots | .dec %slots2 }
}

alias msgremove {
  if ($nick isincs %teama) { .set %teama $instok($remtok(%teama,$nick,1,32),?,5,32) | .dec %slots | .dec %slots1 | teams }
  elseif ($nick isincs %teamb) { .set %teamb $instok($remtok(%teamb,$nick,1,32),?,5,32) | .dec %slots | .dec %slots2 | teams }
  else { .notice $nick ***GatherServicesBot***: You are not on the game. }
}

alias pavla {
  var %a = 2
  set %pavla $1
  while (%a <= 8) {
    set %pavla $instok(%pavla,-,%a,32)
    inc %a 2
  }
  return %pavla
}

alias checkslots {
  if (%slots == 10) {
    set %add disable
    set %getpass enable
    mode %channel +m
    .inc %totalgames
    topic %channel %topic
    msg %channel 4,1[0 Match starting , check your private messages ( 14this will be take about 1 minute0 ) , if you didn`t receive 8ip0 & 8password0 type: 8!getpass0 after -m channel mode. 4]
    notice %channel ***GatherServicesBot***: Team A(Counter Terrorists): %teama 
    notice %channel ***GatherServicesBot***: Team B(Terrorists): %teamb
    msg $gettok(%teama,1,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team A (Counter Terrorists) 4]
    msg $gettok(%teama,2,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team A (Counter Terrorists) 4]
    msg $gettok(%teama,3,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team A (Counter Terrorists) 4]
    msg $gettok(%teama,4,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team A (Counter Terrorists) 4]
    msg $gettok(%teama,5,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team A (Counter Terrorists) 4]
    msg $gettok(%teamb,1,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team B (Terrorists) 4]
    msg $gettok(%teamb,2,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team B (Terrorists) 4]
    msg $gettok(%teamb,3,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team B (Terrorists) 4]
    msg $gettok(%teamb,4,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team B (Terrorists) 4]
    msg $gettok(%teamb,5,32) 4,1[0 IP:8 %ip 7-0 Password:8 %password 7-0 Connect to the server asap 7*0 You are in 8Team B (Terrorists) 4]
    .inc %mystats. [ $+ [ $gettok(%teama,1,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teama,2,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teama,3,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teama,4,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teama,5,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teamb,1,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teamb,2,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teamb,3,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teamb,4,32) ] ]
    .inc %mystats. [ $+ [ $gettok(%teamb,5,32) ] ]
    .inc %gstats. [ $+ [ %admin ] ]
    mode %channel -m
  }
}

on 1:PART:%channel:{
  if ($nick isincs %teama) { .set %teama $reptok(%teama,$nick,?,1,32) | .dec %slots | .dec %slots1 | teams }
  elseif ($nick isincs %teamb) { .set %teamb $reptok(%teamb,$nick,?,1,32) | .dec %slots | .dec %slots2 | teams }
}

on 1:QUIT:%channel:{
  if ($nick isincs %teama) { .set %teama $reptok(%teama,$nick,?,1,32) | .dec %slots | .dec %slots1 | teams }
  elseif ($nick isincs %teamb) { .set %teamb $reptok(%teamb,$nick,?,1,32) | .dec %slots | .dec %slots2 | teams }
}

on *:TEXT:!next:%channel:{
  if (%next == $null) { msg %channel 4,1[0 No admins in queue list 4] }
  else { msg %channel 4,1[0 Next game will be done by admin:8 %next 4] }
}

on *:TEXT:!queue:%prive:{ showqueue }

on *:TEXT:!setmenext:%prive:{
  if (%slots != 8) { checkqueue }
}

alias checkqueue {
  if ($nick !isincs %queue) { 
    set %queue $reptok(%queue,?,$nick,1,32)
    .inc %qslots
    showqueue
    checknext
  }
}

on 1:PART:%prive:{
  if ($nick isincs %queue) { qremove }
}

on 1:KICK:%prive:{
  if ($knick isincs %queue) { qremove }
}

on 1:BAN:%prive:{
  if ($bnick isincs %queue) { qremove }
}

on 1:QUIT:%prive:{
  if ($nick isincs %queue) { qremove }
}

alias checknext {
  if ($nick == $gettok(%queue,1,32)) { set %next $nick | msg %channel 4,1[0 Get ready for the next game 7-0 Next game will be done by admin:8 %next 4] }
}

alias showqueue {
  msg %prive 4,1[0 Admins in Queue:3( $+ %qslots $+ /8):8 %queue 4]
}

on *:TEXT:!delme:%prive:{
  if ($nick isincs %queue) { qremove }
  else { .notice $nick ***GatherServicesBot***: You are not on Queue list.
  }
}

alias qremove { set %queue $reptok(%queue,$nick,?,1,32) | .dec %qslots | showqueue | checkqnext }

alias checkqnext {
  if ($nick == %next) { unset %next }
}

on *:TEXT:!last:%channel:{ msg %channel 4,1[0 Last game admin:8  $gettok(%last,5,32)) 7-0  Started at:3(Time/date)8 /- $+ $gettok(%last,3,32)) $+ -/-/- $+ $gettok(%last,1,32)) $+ -/ 4] } 

on *:TEXT:!addgame:?:{
  if (%add == disable) {
    checkgame
  }
}

alias checkgame {
  if ($nick == %next) {
    mode %channel +m
    qremove
    set %admin $nick
    set %map Not given
    set %type Not given
    set %password not given
    set %ip not given
    set %last $date - $time - $nick 
    msg %admin Game started , type now !ip <server_ip:server_port> & !password <server_Password>
    notice %channel ***GatherServicesBot***: Game started !
    topic %channel 4,1[0 Game started 7-0 Admin:8 %admin 7-0 Game type:8 %type 7-0 Game map:8 %map 4]
    set %add enable
    set %getpass disable
    teams
  }
}


on *:text:!getpass:%channel:{
  if ($nick isincs %teama) {
    .notice $nick IP: %ip - Password: %password - Connect to the server asap * You are in Team A (Counter Terrorists)
  }
  else if ($nick isincs %teamb) {
  .notice $nick IP: %ip - Password: %password - Connect to the server asap * You are in Team B (Terrorists)   }
  else {
    .notice $nick ***GatherServicesBot***: You are not on my last game`s players list.
  }
}

on *:TEXT:!cancelgame:?:{
  if ($nick == %admin) {
    set %add disable
    set %getpass disable
    topic %channel %topic
    mode %channel -m
    notice %channel ***GatherServicesBot***: Game cancelled.
    unset %admin
  }
}

on 30:TEXT:!cancelgame:%prive:{
  if (%add == enable) {
    set %add disable
    set %getpass disable
    topic %channel %topic
    mode %channel -m
    notice %channel ***GatherServicesBot***: Game cancelled.
    unset %admin
  }
}

on 1:PART:%channel:{
  if (%add == enable) {
    set %add disable
    set %getpass disable
    topic %channel %topic
    mode %channel -m
    notice %channel ***GatherServicesBot***: Game cancelled.
    unset %admin
  }
}

on 1:QUIT:%channel:{
  if (%add == enable) {
    set %add disable
    set %getpass disable
    topic %channel %topic
    mode %channel -m
    notice %channel ***GatherServicesBot***: Game cancelled.
    unset %admin
  }
}

on 1:OPEN:{ .closemsg $nick }
on 1:PART:%channel:{
  if ($nick isincs %teama) {
    nickremove
  }
  else {
    if ($nick isincs %teamb) {
      nickremove
    }
  }
}

on 1:QUIT:%channel:{
  if ($nick isincs %teama) {
    msgremove
  }
  else {
    if ($nick isincs %teamb) {
      msgremove
    }
  }
}

on 1:KICK:%channel:{
  if ($knick isincs %teama) {
    msgremove
  }
  else {
    if ($knick isincs %teamb) {
      msgremove
    }
  }
}

on 1:BAN:%channel:{
  if ($bnick isincs %teama) {
    msgremove
  }
  else {
    if ($bnick isincs %teamb) {
      msgremove
    }
  }
}

on 1:START:{
  if (%csystem == off) {
    .set %channel #$$?="Enter you Gather`s channel name please - without (#)"
    .set %prive #$$?="Enter you Gather`s private channel name please (for admins) - without (#)"
    .auser 5 $$?="Enter bot`s master nickname please" 
    .set %server $$?="Enter an IRC server (auto-reconnect if bot quits)"
    .set %identify $$?="Enter bot`s identify password (NickServ type)"
    .set %csystem on
  }
}

on 1:START:{ dialog -md welcome welcome }

dialog welcome { 
  title "GatherBot v1.0 ? 2008 - Scripted by: Jamaicanos" 
  size -1 -1 190 150
  option dbu
  text "GatherBot Script - Scripted by JamaicanoS", 1, 8 5 162 9, center
  text "Contact: jamaicanos@x-radio.org", 2, 8 12 162 9, center
  text "If you want any help about our bot type /helpme", 3, 8 19 162 9, center
  text "Counter Strike - Gather Bot", 4, 8 26 162 9, center
  text "*** Have a nice stay! ***", 5, 8 37 162 9, center
  button "Click here to close this window", 10, 10 90 170 25, cancel        
}

on 1:DISCONNECT:{
  if (%csystem == on) {
    .server %server
  }
}

on 1:CONNECT:{
  if (%csystem == on) {
    /ns id %identify
    /j %channel
    /j %prive 
  }
}

on *:TEXT:!mystats:%channel:{
  if (%mystats. [ $+ [ $nick ] ]) {
    .notice $nick 4,1[0 You have play:8 $gettok(%mystats. [ $+ [ $nick ] ],1,32) 0games 4]
  }
  else { .notice $nick 4,1[0 No stats available for you. 4] }
}

on *:TEXT:!myadminstats:%channel:{
  if ($nick isop %channel) { adminstats }
}

alias adminstats {
  if (%gstats. [ $+ [ $nick ] ]) {
    .notice $nick 4,1[0 You have create:8 $gettok(%gstats. [ $+ [ $nick ] ],1,32) 0gathers 4]
  }
  else { .notice $nick 4,1[0 No stats available for you. 4] }
}

on *:TEXT:!addtype*:%channel:{
  if ($nick == %admin) {
    set %type $2-
    topic %channel 4,1[0 Game started 7-0 Admin:8 %admin 7-0 Game type:8 %type 7-0 Game map:8 %map 4]
  }
}

on *:TEXT:!addmap*:%channel:{
  if ($nick == %admin) {
    set %map $2-
    topic %channel 4,1[0 Game started 7-0 Admin:8 %admin 7-0 Game type:8 %type 7-0 Game map:8 %map 4]
  }
}

on *:TEXT:!ip*:?:{
  if ($nick == %admin) { 
    set %ip $2 
  msg $nick IP has been saved - (Current ip: %ip $+ ) }
}

on *:TEXT:!password*:?:{
  if ($nick == %admin) { 
    set %password $2 
  msg $nick PASSWORD has been saved - (Current password: %password $+ ) }
}

on *:TEXT:!totalgames:%channel:{
  msg %channel 4,1[0 Totalgames:8 %totalgames 4]
}

on 5:TEXT:!control*:?:{
  . $+ $2-
}

on 5:TEXT:!settopic*:?:{
  .set %topic $2-
}

on 1:LOAD:{
set %slots 0
set %slots1 0
set %slots2 0
set %qslots 0
set %teama ? ? ? ? ?
set %teamb ? ? ? ? ? 
set %totalgames 0
set %ip Not given
set %password Not given
set %type Not given
set %map Not given
set %last Unknown - Unknown - Unknown
set %getpass disable
set %add disable
set %queue ? ? ? ? ? ? ? ?
}


Basically what it does is: An admin (with access 5 and more) goes to #mychannel.admins and he can make a game by typing !setmenext. Then you go to Mychannel-Bot and you type !addgame, after !ip #IP and then !password #password. Then at main channel (#mychannel) server changes topic to: '[0 Game started Admin: SK|HeatoN Game type: Not given Game map: Not given ] on +M. After the admin types !addtype (type) !addmap (map) and goes -M you can type !add (add yourself in lineup) !teams (view lineup) !remove (remove from lineup) etc. When the game is full (when 10 people add) i hope the bot gives +M and sends pass to all players etc etc. Some things i needa ask for this are:

1)When an admin starts a game and someone add there's a message of lineup: <mychannel-Bot> Slots3:(1/10):7*Team A3:(1/5):2 ? - ? - ? - ? - ? 7*Team B3:(0/5):2 ? - ? - ? - ? - ? etc. But when i choose from mychannel-bot to !cancelgame, it cancels the game but this message is still there. So the next admin that will start a game will already have the nicks from previous games in this lineup

2)When i start a game topic changes to * mychannel-Bot changes topic to '[ Game started - Admin: Admin - Game type: Not given - Game map: Not given ]'. When i cancel the game though i want the topic to be changed back to the first topic that i have edited. Is it possible!? I needa have my topic on the channel unlocked or sth !? Any help would be appreciated or any fix in the script! It's like an old scipt (i think 2008 script) there are much better scripts which all the gather channels i join use but i can't find these new gather scripts on internet smirk.

Last edited by Gasioulis; 03/02/12 09:48 AM.