Socket Bot

By Merbo on Apr 16, 2011

Aliases:
/bot.start
Connects the socket bot to the server and port you specify.
/bot.join
Makes the bot join a channel.
/bot.part
Makes the bot part a channel.
/bot.ownermask <hostmask/nick (no wildcards)>
Sets the bot's owner.
In channel commands:

Owner only:

!dummybot create
!dummybot kill
!dummybot join
!dummybot part
Makes a DUMMY bot do various things, dummybots are for testing bots :P

!obey <hostmask/nick (no wildcards)>
Makes the bot set the specified host/name as its master.

!cmd <command prompt command, one line>
Runs a command prompt and runs command specified.

!flags
!mlock
sets things using chanserv.

!identify
Identifies to NickServ, make sure you set its pass and user in private first....

!port
Specifies the port the bot should DCC to.

!anonto
Who the bot will tell about whoever private messages it with commands.

!dcc
DCC's a user specified file.

Bot master/higher commands:

!mode
!topic
!hostmask
!banmask
!longmode
!op
!deop
!voice
!devoice
!botop
!botdeop
!botvoice
!botdevoice
!ban
!unban
!nick
!kick [reason]
!kickban [reason]
!raw

All user commands:

!ping
!invite
!calc
!tan, !cos, !acos, !root, !atan, !sin, !asin, !log
!ctcp
!roll [sides]
!say
!do
!tell <user/chan>
!desc <user/chan>
!myfullmask

In private commands:

!nickservuser
Sets what nickserv account the bot should use for identifying.
!nickservpass
Sets what the nickserv account's password is.

This bot supports CTCP and DCC.
(try to //ctcp %botnick VERSION)

alias bot.start sockclose socketbot | sockopen socketbot $$1 $$2
alias bot.join sockwrite -n socketbot JOIN $$1 $2-
alias bot.part sockwrite -n socketbot PART $$1 $2-
alias bot.say sockwrite -n socketbot PRIVMSG $1 : $+ $2-
alias bot.act sockwrite -n socketbot PRIVMSG $1 $+(:,$chr(1),ACTION $2- $chr(1))
alias bot.chgnick sockwrite -n socketbot NICK $1 | %botnick = $1
alias bot.die sockwrite -n socketbot QUIT Closed by $me | sockclose socketbot
alias bot.mode sockwrite -n socketbot MODE $$1 $$2-
alias bot.topic sockwrite -n socketbot TOPIC $$1 : $+ $$2-
alias bot.invite sockwrite -n socketbot INVITE $$1 $$2
alias bot.whois sockwrite -n socketbot WHOIS $$1
alias bot.notice sockwrite -n socketbot NOTICE $$1 : $+ $$2-
alias bot.log run $mircdir $+ /socketbotlog.txt
alias bot.kick {
  if ($3) { sockwrite -n socketbot KICK $$1 $$2 : $+ $3- }
  elseif (!$3) { sockwrite -n socketbot KICK $$1 $$2 : $+ $$2 }
}
alias bot.raw sockwrite -n socketbot $$1-
alias bot.identify bot.say NickServ identify %identify.user %identify.pass
alias bot.connectnick %botnick = $?="What nick?"
alias bot.ownermask /set %botownermask $$1 | /bot.say $me Done. Bot owner is now set to %botownermask 
alias bot.mastermask /set %botmastermask $$1 | /bot.say $me Done. Bot master is now set to %botmastermask
on *:SOCKOPEN:socketbot: {
  sockwrite -n $sockname USER %botnick 0 0 : $+ %botnick
  sockwrite -n $sockname NICK %botnick
  if (!$sockerr) echo -a 8Connected the socket bot.
  else echo -a 8Error, connection closed.
}
on *:SOCKOPEN:dummybot: {
  sockwrite -n $sockname USER %dummyname 0 0 : $+ dummybot
  sockwrite -n $sockname NICK %dummyname
  sockwrite -n $sockname JOIN %dummychan
  if (!$sockerr) /bot.say %dummychan dummybot coming online...
  else /bot.say %dummychan Error! Error: $sockerr
}
on *:SOCKREAD:dummybot: {
  var %dummybot
  sockread -f %dummybot
  tokenize 32 %socketbot
  if ($1 == PING) { sockwrite -n $sockname PONG $2 }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == $chr(1) $+ VERSION $+ $chr(1)) { /bot.notice $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $chr(1) $+ %botnick Self-created dummybot $+ $chr(1) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == $chr(1) $+ TIME $+ $chr(1)) { /bot.notice $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $chr(1) $+ TIME $time (hour:minute:second) $+ $chr(1) }
}
on *:SOCKREAD:socketbot: {
  var %socketbot
  sockread -f %socketbot
  tokenize 32 %socketbot
  if ($1 == PING) { sockwrite -n $sockname PONG $2 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !dummybot) && ($5 == create) { /set %dummychan $3 | /set %dummyname $6 | /sockopen dummybot $sock(socketbot).addr 6667 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !dummybot) && ($5 == kill) { sockwrite -n dummybot QUIT :Killed by %botnick using the local console. | .timer 1 3 /sockclose dummybot | /bot.say $3 dummybot killed successfully. }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !dummybot) && ($5 == join) { sockwrite -n dummybot JOIN $6 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !dummybot) && ($5 == part) { sockwrite -n dummybot PART $6 | /bot.say $3 dummybot }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !obey) { %botmastermask = $5 | .timer 1 1 bot.say $3 I shall now obey the hosts of %botmastermask }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !NickServUser) { /set %identify.user $$5 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !cmd) { .run C:\Windows\System32\cmd.exe /Q /K $5- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !NickServPass) { /set %identify.pass $$5- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !flags) { /bot.say ChanServ FLAGS $3 $5- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !mlock) { /bot.say ChanServ SET $3 MLOCK $5- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !identify) { /bot.identify }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !port) { %dcc.port = $$5 | /bot.say $3 DCC Port is now $$5 $+ . }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) && ($right($4,-1) == !anonto) { %anonto = $$5 | /bot.say $3 I will tell all anonymous messages to $$5 $+ . }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !mode) { /bot.mode $3 $$5 $6- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !topic) { /bot.topic $3 $5- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !hostmask) { /bot.whois $$5 | /set %hostcaller $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $+ : | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.full True }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !banmask) { /bot.whois $$5 | /set %hostcaller $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $+ : | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.ban True }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !longmode) { /bot.mode $$5 $$6 $7- }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !op) {  /bot.say ChanServ op $3 | .timer 1 1 bot.mode $3 +o $$5 | .timer 1 1 bot.say ChanServ deop $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !deop) { /bot.say ChanServ op $3 | .timer 1 1 bot.mode $3 -o $$5 | .timer 1 1 bot.say ChanServ deop $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !voice) { /bot.say ChanServ op $3 | .timer 1 1 bot.mode $3 +v $$5 | .timer 1 1 bot.say ChanServ deop $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !devoice) { /bot.say ChanServ op $3 | .timer 1 1 bot.mode $3 -v $$5 | .timer 1 1 bot.say ChanServ deop $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !botop) { /bot.say ChanServ op $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !botdeop) { /bot.say ChanServ deop $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !botvoice) { /bot.say ChanServ voice $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !botdevoice) { /bot.say ChanServ devoice $3 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !ban) { /bot.whois $$5 | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.doban True } 
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !unban) { /bot.whois $$5 | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.dounban True } 
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !except) { /bot.whois $$5 | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.doexcept True }
  elseif ($2 == 311) {
    if (%host.full == True) { /set %hostmask $4 $+ ! $+ $5 $+ @ $+ $6 | /set %host.full False | .signal hostmask }
    elseif (%host.ban == True) { /set %hostmask *!*@ $+ $6 | /set %host.ban False | .signal banmask }
    elseif (%host.doban == True) { /set %hostmask *!*@ $+ $6 | /set %host.doban False | .signal bantime }
    elseif (%host.dounban == True) { /set %hostmask *!*@ $+ $6 | /set %host.dounban False | .signal unbantime }
    elseif (%host.doexcept == True) { /set %hostmask *!*@ $+ $6 | /set %host.doexcept False | .signal excepttime }
    elseif (%host.dcc == True) { /set %hostmask $4 $+ ! $+ $5 $+ @ $+ $6 | /set %host.dcc False | .signal dcctime }
  }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !nick) { /bot.chgnick $$5 }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !kick) { 
    if ($6) /bot.kick $3 $$5 $6- 
    else /bot.kick $3 $$5 $$5 
  } 
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !kickban) { /bot.kick $3 $$5 $6- | /bot.whois $$5 | /set %bot.hostmaskchan $3 | /set %bot.hostmasktarget $$5 | /set %host.doban True }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !raw) { /bot.raw $$5- }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !ping) { /bot.say $3 Pong. }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !invite) { /bot.invite $3 $5 }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !calc) { /bot.say $3 Solution: $calc($5-) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !tan) { /bot.say $3 Solution: $tan($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !cos) { /bot.say $3 Solution: $cos($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !acos) { /bot.say $3 Solution: $acos($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !root) { /bot.say $3 Solution: $sqrt($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !atan) { /bot.say $3 Solution: $atan($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !sin) { /bot.say $3 Solution: $sin($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !asin) { /bot.say $3 Solution: $asin($calc($5-)) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !log) { /bot.say $3 Solution: $log($calc($5-)) }
  elseif ($2 == PRIVMSG) && (%botownermask isin $right($1,-1)) || (%botmastermask isin $right($1,-1)) && ($right($4,-1) == !dcc) { /bot.whois $$5 | /set %bot.hostmasktarget $$5 | /set %host.dcc True | /set %dcc.file $$6 }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == $chr(1) $+ VERSION $+ $chr(1)) { /bot.notice $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $chr(1) $+ VERSION Merbo's mIRC Socket Bot $+ $chr(1) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == $chr(1) $+ TIME $+ $chr(1)) { /bot.notice $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $chr(1) $+ TIME $time (hour:minute:second) $+ $chr(1) }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !ctcp) { /set %ctcp $6- | /set %ctcpuser $$5 | /set %ctcpchan $3 | /bot.say %ctcpuser $chr(1) $+ %ctcp $+ $chr(1) }
  elseif ($2 == NOTICE) && ($remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) == %ctcpuser) { /bot.say %ctcpchan %ctcpuser $+ 's %ctcp Reply: $remove($5-,$chr(1)) | /unset %ctcp | /unset %ctcpuser | /unset %ctcpchan }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !roll) { 
    if (!$5) { 
      /bot.say $3 You rolled $r(1,6) $+ . 
    } 
    else { 
      /bot.say $3 You rolled $r(1,$5) $+ . 
    } 
  }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !say) { /bot.say $3 $$5- }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !do) { /bot.act $3 $$5- }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !tell) { /bot.say $$5 $$6- | if ($left($3,1) != $chr(35)) { /bot.say %anonto $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) told me to say " $+ $6- $+ " to $5 $+ . } }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !desc) { /bot.act $$5 $$6- | if ($left($3,1) != $chr(35)) { /bot.say %anonto $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) told me to act " $+ $6- $+ " to $5 $+ . } }
  elseif ($2 == PRIVMSG) && ($right($4,-1) == !myfullmask) { /bot.say $3 $remove($left($right($$1,-1),$pos($right($$1,-1),!,1)),!) $+ : $right($1,-1) }
  window -k0 +e @socketbot
  aline @socketbot $1-
  write socketbotlog.txt $1-
}
on *:SIGNAL:hostmask: { /bot.say %bot.hostmaskchan %hostcaller %bot.hostmasktarget $+ 's hostmask: %hostmask | /halt }
on *:SIGNAL:dcctime: { /bot.say %bot.hostmasktarget $chr(1) $+ DCC SEND %dcc.file %hostmask %dcc.port $+ $chr(1) }
on *:SIGNAL:banmask: { /bot.say %bot.hostmaskchan %hostcaller %bot.hostmasktarget $+ 's banmask: %hostmask | /halt }
on *:SIGNAL:bantime: { /bot.mode %bot.hostmaskchan +b %hostmask | /halt }
on *:SIGNAL:unbantime: { /bot.mode %bot.hostmaskchan -b %hostmask | /halt }  
on *:SIGNAL:excepttime: { /bot.mode %bot.hostmaskchan +e %hostmask | /halt }
on *:LOAD: {
  /bot.connectnick
}

Comments

Sign in to comment.
CoLoNeL   -  Dec 20, 2017

bakan kımse yokmu

 Respond  
CoLoNeL   -  Dec 20, 2017

Calışmıyo BagLanmıyor

 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.