TS3 Interaction V1.3

By dronez4 on Jan 29, 2014

  • Same features from V1.2 that was made by prulez but modified by dronez4
    Less buggy than before
    * Added admin channel features
    *** Added incoming and outgoing IP Addresses and ID's
    Dialog added admin button
    ** added !ts ip command
    *** added !ts ID command
    **** added cross-relay channel communication
;********************************************
;TeamSpeak 3 Script Originally by prulez, edited by dronez4
;----------
;This script is a modification of the original TS3 script that was originally by Prulez but edited for better use by dronez4
;----------
;New features added for an admin channel - dronez4
;*******************************************
;* Same features from V1.2 that was made by prulez but modified by dronez4
;** Less buggy than before
;*** Added admin channel features
;**** Added incoming and outgoing IP Addresses and ID's
;***** Dialog added admin button
;****** added !ts ip command
;******* added !ts ID command
;******** added cross-relay channel communication
;================================
;===== on LOAD event

on *:LOAD: {
  ts3setup
  set %ts.sversion 1.3
  echo -a 7TeamSpeak 3 Script modified by dronez4 has been loaded! Version %ts.sversion
  echo -a 11Support will ONLY be given at the RenCorner community
  echo -a 11Website: http://www.RenCorner.com
  echo -a 11IRC: irc.RenCorner.com
  echo -a ----------
  echo -a TS3 Interaction V1.3
  echo -a ----------
  echo -a 11When you have encountered any bugs, or have any suggestions, then please contact me at the site or IRC given above.
  echo -a 11Thanks and have fun with my script!
}

;================================
;===== Menu & Setup Dialog

menu menubar,channel,status,query,nicklist,statusbar { 
  TS3 Interaction
  .Setup:/ts3setup
  .Readme://run $scriptdir $+ ts3readme.txt
  .-
  .Display Server Info:/ts3info %ts.channels
  .Display Users:/ts3users %ts.channels
  .Display Channels:/ts3channels %ts.channels
  .-
  .Kick Client:/ts3kick $$input(What is the nickname of the client you want to kick?, e) $+ ; $+ $$input(What is the reason you want to kick this user?, e) $+ ; $+ $me $+ ; $+ %ts.channels
  .Ban Client:/ts3ban $$input(What is the nickname of the client you want to ban?, e) $+ ; $+ $$input(What is the reason you want to ban this user?, e) $+ ; $+ $me $+ ; $+ %ts.channels
  .-
  .Message Server:/ts3msg $me $+ ; $+ $$input(What's the message that you want to send?, e)
  .PM Client:/ts3pm $$input(What is the nickname of the client you want to PM?, e) $+ ; $+ $$input(What's the message that you want to send?, e) $+ ; $+ $me $+ ; $+ %ts.channels
  .Poke Client:/ts3poke $$input(What is the nickname of the client you want to Poke?, e) $+ ; $+ $$input(What's the message that you want to send?, e) $+ ; $+ $me $+ ; $+ %ts.channels
  .-
  .Advertise Script:/ts3version %ts.channels
}

alias ls1 {
  var %count = $findfile(%tsdirectory, *.log, 0), %i = 1, %latest_time = 0, %latest
  while (%i < %count) {
    var %t_file = $findfile(%tsdirectory, *.log, %i)
    var %t_time = $file(%t_file).mtime
    if (%t_time > %latest_time) {
      %latest = %t_file
      %latest_time = %t_time
    }
    inc %i
  }
  set %lss $replace(%t_file,_0.log,_1.log)
}

alias html2chr return $replace($regsubex($1-,/(&#(\d*));?/g,$chr(\2)),&nbsp;,$chr(32),&amp;,&)

alias ts3setup {
  /dialog -m ts3setup ts3setup
}

dialog ts3setup {
  ;MAIN DIALOG INFO
  title TS3 Interaction Setup - Version %ts.sversion modified version
  size -1 -1 200 260
  option dbu

  ;MAIN BOXES
  box "Channels", 1, 1 1 99 116 
  box "Server Info", 2, 101 1 99 116
  box "Timeout", 3, 1 118 99 52
  box "Login Info", 4, 101 118 99 52

  ;CHANNELS
  edit "#", 5, 3 8 70 10 
  button "Add", 6, 75 8 20 10
  list 7, 3 19 95 90
  button "Delete Channel", 8, 3 105 95 10

  ;SERVER INFO
  box "Server IP", 9, 103 8 95 20
  edit %ts.ip, 10, 105 15 90 10, %ts.ip
  box "Query Port", 11, 103 29 95 20
  edit %ts.qport, 12, 105 36 90 10, %ts.qport
  box "Public IP", 13, 103 50 95 32
  edit %ts.ip.public, 14, 105 57 90 10, %ts.ip.public
  text "The IP clients have to enter in the TS3 client to connect to the server", 15, 107 67 90 15
  box "Server Port", 16, 103 83 95 32
  edit %ts.sport, 17, 105 90 90 10, %ts.sport
  text "The port clients have to enter in the TS3 client to connect to the server", 18, 107 100 90 15

  ;TIMEOUT
  edit %ts.timeout, 19, 3 127 95 10, %ts.timeout
  text "The amount of seconds before the script assumes the server has timed out when it has stopped responding.", 20, 5 138 90 20

  ;LOGIN INFO
  box "Username", 21, 103 126 95 20
  edit %ts.slogin, 22, 105 133 90 10, %ts.slogin
  box "Password", 23, 103 147 95 20
  edit %ts.spass, 24, 105 154 90 10, %ts.spass

  ;OK & CANCEL BUTTONS
  button "Save and Exit", 25, 60 242 40 10, ok
  button "Cancel", 26, 101 242 30 10, cancel
  ;Admin channel & Log directory - for example c:/ts3server/logs/
  button "Admin channel" 27, 101 180 50 14
  edit "",28, 27 182 70 10
  button "TSLog directory" 29, 101 210 50 14
  edit "",30, 27 212 70 10

}

on *:DIALOG:ts3setup:*:*: {
  if ($devent == sclick) {
    if ($did == 29) {
      if ($did(30) != $null) {
        set %tsdirectory $did(30)
      }
      else {
        did -r ts3setup 30
        did -a ts3setup 30 Fill this in.
      }
    }
    if ($did == 27) {
      if ($did(28) != $null) {
        set %ts-admin $did(28)
      }
      else {
        did -r ts3setup 28
        did -a ts3setup 28 Fill this in. 
      }
    }
    if ($did == 6) {
      did -a ts3setup 7 $did(ts3setup,5)
      did -ra ts3setup 5 [ $chr(35) ]
    }
    if ($did == 8) {
      did -d ts3setup 7 $did(ts3setup,7).sel
    }
    if ($did == 25) {
      set %ts.channels $didtok(ts3setup,7,44)
    }
  }
  if ($devent == init) {
    did -a ts3setup 28 %ts-admin
    did -a ts3setup 30 %tsdirectory
    didtok ts3setup 7 44 %ts.channels
  }
}

;==========================
;====== Aliases

; ***Converting HTML output to readable output***
alias htmlconv {
  var %t, %u = $regsub($replace($1,<br>,$crlf),/^[^<]*>|<[^>]*>|<[^>]*$/g,,%t)
  if (!$regex(%t,/&\S+?;/)) return %t
  if ($prop == rem) { !.echo -q $regsub(%t,/&\S+?;/g,,%t) | return %t }
  %t = $replace(%t,&nbsp;,$chr(160),&quot;,",&lt;,<,&gt;,>,&amp;,&,&hellip;,...,&reg;,®, $&
    &copy;,©,,&trade;,™,&frac14;,¼,&frac12;,½,&frac34;,¾,&sup3;,³,&sup2;,²,&deg;,°,&bull;,•, $&
    &rsaquo;,›,&lsaquo;,‹,&raquo;,»,&laquo;,&rsquo;,’,&lsquo;,‘,&rdguo;,”,&ldquo;,“,&ndash;, $&
    –,&mdash;,—,&apos;,',&tilde;,~,&times;,×,&divide;,÷,&para;,¶,&ecute;,é,&Ecute;,É,&cent;, $&
    ¢,&pound;,£,&yen;,¥,&sect;,§)
  if ($version < 6.14) || (!$regex(%t,/&\S+?;/)) return %t
  var %html = html $+ $ticks, %body = body $+ $ticks
  .comopen %html htmlfile
  if ($comerr) return %t
  %t = $com(%html,write,1,bstr*,$+(<html><body>,%t,</body></html>))
  %t = $com(%html,body,2,dispatch* %body) $com(%body,innertext,2)
  %t = $com(%body).result
  :error
  if ($com(%body)) .comclose %body
  if ($com(%html)) .comclose %html
  return %t
}

; ***Connecting to the server***
alias ts.connect { sockclose ts3 | if $hget(ts3) { .hfree ts3 } | msg %ts.channels 7[TS3] Attempting to connect to the TS3 server.. | sockopen ts3 %ts.ip %ts.qport | .timertsconfail 1 15 ts.sockclose cc }

; ***Writing to the server***
alias ts3.d { if $sock(ts3) { sockwrite -n ts3 $1- } }

; ***"Translating" output from the server to normal things that's readable***
alias ts.clean { return $htmlconv($remove($replace($replace($replace($1-, \s, $chr(32)), \p, $chr(124)), \/, /),<,>,,,,,,,)) }

; ***"Translating" input (Messages) to blahblah that the TS3 server can read***
alias ts.input { return $replace($replace($1-, $chr(32), \s), $chr(124), \p) }

; ***!TS Info***
alias ts3info {
  set %ts.getclientlist 1
  set %ts.infochan $1-
  ts3.d channellist
  ts3.d clientlist -away
  ts3.d serverinfo
}

; ***!TS Users***
alias ts3users {
  set %ts.getclientlist 1
  set %ts.userchan $1-
  set %ts.showclientlist 1
  ts3.d channellist
  ts3.d clientlist -away
}

; ***!TS Channels***
alias ts3channels {
  set %ts.displaychanlist 1
  set %ts.chanchan $1-
  ts3.d channellist
}

; ***!TS Msg***
alias ts3msg {
  var %nick = $gettok($1-, 1, 59)
  var %msg = $gettok($1-, 2, 59)
  var %message = $ts.input(( $+ %nick $+ @IRC) %msg)
  ts3.d gm msg= $+ %message
}

; ***!TS Ban***
alias ts3ban {
  var %client = $gettok($1-, 1, 59)
  var %reason = $gettok($1-, 2, 59)
  var %banner = $gettok($1-, 3, 59)
  var %chan = $gettok($1-, 4, 59)
  var %hash = $hfind(ts3, %client $+ *, 1, w)
  if (!%hash) { msg $1- 7[TS3] 9[Ban] 11Unable to find client. | HALT }
  else {
    var %nick = $gettok(%hash, 1, 59)
    var %clid = $gettok(%hash, 2, 59)
    var %msg = $ts.input(( $+ %banner $+ @IRC) %reason)
    set %ts.act ban
    set %ts.banchan %chan
    ts3.d banclient clid= $+ %clid banreason= $+ %msg
    msg %ts.channels 7[TS3] 9[Ban] 3Attempting to ban %nick - 11( $+ %banner $+ @IRC) %reason
  }
}

; ***!TS Poke***
alias ts3poke {
  var %client = $gettok($1-, 1, 59)
  var %message = $gettok($1-, 2, 59)
  var %poker = $gettok($1-, 3, 59)
  var %chan $gettok($1-, 4, 59)
  var %hash = $hfind(ts3, %client $+ *, 1, w)
  if (!%hash) { msg %chan 7[TS3] 9[Poke] 11Unable to find client. | HALT }
  else {
    var %nick = $gettok(%hash, 1, 59)
    var %clid = $gettok(%hash, 2, 59)
    var %msg = $ts.input(( $+ %poker $+ @IRC) %message)
    ts3.d clientpoke clid= $+ %clid msg= $+ %msg
    msg %chan 7[TS3] 9[Poke] 3Poked %nick - 11Message: ( $+ %poker $+ @IRC) %message
  }
}

; ***!TS Kick***
alias ts3kick {
  var %client = $gettok($1-, 1, 59)
  var %message = $gettok($1-, 2, 59)
  var %kicker  $gettok($1-, 3, 59)
  var %chan $gettok($1-, 4, 59)
  var %hash = $hfind(ts3, %client $+ *, 1, w)
  if (!%hash) { msg %chan 7[TS3] 9[Kick] 11Unable to find client. | HALT }
  else {
    var %nick = $gettok(%hash, 1, 59)
    var %clid = $gettok(%hash, 2, 59)
    var %msg = $ts.input(( $+ %kicker $+ @IRC) %message)
    set %ts.act kick
    set %ts.kickchan %chan
    if ($len(%msg) > 40) { msg %chan 7[TS3] 9[Kick] 11Kick message is too long. Limiting it to 40 characters.. | var %msg = $left(%msg, 40) }
    ts3.d clientkick clid= $+ %clid reasonid=5 reasonmsg= $+ %msg
    msg %chan 7[TS3] 9[Kick] 3Attempting to kick %nick - 11( $+ %kicker $+ @IRC) %message
  }
}

; ***!TS PM***
alias ts3pm {
  var %client = $gettok($1-, 1, 59)
  var %message = $gettok($1-, 2, 59)
  var %pmer  $gettok($1-, 3, 59)
  var %chan $gettok($1-, 4, 59)
  var %hash = $hfind(ts3, %client $+ *, 1, w)
  if (!%hash) { msg %chan 7[TS3] 9[PM] 11Unable to find client. | HALT }
  else {
    var %nick = $gettok(%hash, 1, 59)
    var %clid = $gettok(%hash, 2, 59)
    var %msg = $ts.input(( $+ %pmer $+ @IRC) %message)
    ts3.d sendtextmessage targetmode=1 target= $+ %clid msg= $+ %msg
    msg %chan 7[TS3] 9[PM] 3PM sent to %nick - 11( $+ %pmer $+ @IRC) %message
  }
}

; ***!TS Version***
alias ts3version {
  set %ts.sversion 1.3
  msg $1- 7[TS3] 3[Author] 11This script has been made by Prulez and modified by dronez4 for http://www.rencorner.com
  msg $1- 7[TS3] 3[Version] 11Script version: %ts.sversion
}

; ***Displaying the userlist when requested***
alias ts.displaylist {
  var %totalhash = $hget(ts3, 0).item
  if (%totalhash == 0) {
    msg %ts.userchan 7[TS3] 9No users are currently online.
  }
  if (%totalhash != 0) {
    var %a = 1 
    while (%a <= %totalhash) {
      var %hashname = $hget(ts3, %a).item
      var %cid = $gettok($gettok($hget(ts3, %hashname), 1, 59), 2, 61)
      var %channame = $ts.clean($gettok($hget(ts3chan, %cid), 1, 59))
      var %away = $gettok($gettok($hget(ts3, %hashname), 2, 59), 2, 61)
      var %awaymessage = $ts.clean($gettok($gettok($hget(ts3, %hashname), 3, 59), 2, 61))
      var %clnick = $ts.clean($gettok(%hashname, 1, 59))

      msg %ts.userchan 7[TS3] 9[User %a $+ ] 11 $+ %clnick 3( $+ %channame $+ ) $iif(%away == 1, $iif(%awaymessage, 5(Away: %awaymessage $+ ), 5(Away)))
      inc %a 
    }
  }
  unset %ts.userchan
}

;============================
;==== Connecting & Commands

; ***Connects to TS when you join one of the channels (and if the socket isn't already active)***
on *:join:#:if $nick == $me && $findtok(%ts.channels,$chan,1,44) && !$sock(ts3) { ts.connect }

; ***Referring commands to aliases***
on *:TEXT:*:#: {
  if ($chan == %ts-admin) {
    if ($1 == !ts) {
      if ($2 == help) { if ($3 == $null) { msg $chan 7[TS3] 3TeamSpeak Commands: 9!TS Users, IP, ID, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. 
        }
        else {
          if $3 == users { msg # 7[TS3] 9!TS Users - 11Displays information about the currently connected users. }
          elseif $3 == info { msg # 7[TS3] 9!TS Info - 11Lists basic information about the TeamSpeak Server }
          elseif $3 == channels { msg # 7[TS3] 9!TS Channels - 11Displays all channels and the number of users in them. }
          elseif $3 == msg { msg # 7[TS3] 9!TS Msg <message> - 11Sends a message to the server }
          elseif $3 == PM { msg # 7[TS3] 9!TS PM <user> <message> - 11Sends a private message to an user }
          elseif $3 == poke { msg # 7[TS3] 9!TS Poke <user> <message> - 11Pokes an user with the specified message (if any). }
          elseif $3 == kick { msg # 7[TS3] 9!TS Kick <user> <reason> - 11Kicks an user from the server. }
          elseif $3 == ban { msg # 7[TS3] 9!TS Ban <user> <reason> - 11Bans an user from the server. }
          elseif $3 == version { msg # 7[TS3] 9!TS Version - 11Displays information about the script and its author. }
          elseif $3 == ID { msg # 7[TS3] 9!TS ID - 11Displays the last known ID of user }
          elseif $3 == IP { msg # 7[TS3] 9!TS IP - 11Displays the last known IP Address and port of user }
          elseif (!$3) { msg # 7[TS3] 3TeamSpeak Commands: 9!TS Users, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. }
          else { msg # 7[TS3] 4Unknown command. 3TeamSpeak Commands: 9!TS Users, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. }
        }
      }
      if ($2 == info) { ts3info $chan }
      if ($2 == users) { ts3users $chan }
      if ($2 == version) { ts3version $chan }
      if ($2 == channels) { ts3channels $chan }
      if ($2 == msg) { ts3msg $nick $+ ; $+ $3- }
      if ($2 == poke) { ts3poke $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
      if ($2 == ban) {
        if ($nick !ishop $chan) && ($nick !isop $chan) { msg $chan 7[TS3] 9[Ban] 11You lack the required permissions to use this command | HALT }
        else { ts3ban $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
      }
      if ($2 == kick) {
        if ($nick !ishop $chan) && ($nick !isop $chan) { msg $chan 7[TS3] 9[Kick] 11You lack the required permissions to use this command | HALT }
        else { 
          msg %ts.channels 7[TS3] 9[Akick]3 $3 has been kicked by $nick $+ @IRC for: $4- $+ .
        ts3kick $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
      }
      if ($1-2 == !ts pm) {
        ts3pm $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan
      }
    }

    if ($1-2 == !TS ip) && ($2 != $null) {
      if ($readini(idiplog.ini, tsip, $3-) == $null) {
      msg $chan No matches found, Wait for reconnection of user }
      else {
        if ($chr(32) isin $2-) {
          msg $chan 7[TS3]9 Last known IP of $3- $+ : $readini(idiplog.ini, tsip, $replace($3-,$chr(32),_))
        }
        else {
          msg $chan 7[TS3]9 Last known IP of $3 $+ : $readini(idiplog.ini, tsip, $3)
        }
      }
    }
    if ($1-2 == !TS id) && ($2 != $null) {
      if ($readini(idlog.ini, idlog, $3-) == $null) {
      msg $chan No matches found, Wait for reconnection of user }
      else {
        if ($chr(32) isin $2-) {
          msg $chan 7[TS3]9 Last known ID of $3- $+ : $readini(idlog.ini, idlog, $replace($3-,$chr(32),_))
        }
        else {
          msg $chan 7[TS3]9 Last known ID of $3 $+ : $readini(idlog.ini, idlog, $3)
        }
      }
    }
  }
  ; ignores text typed anywhere except the ts channel 
  if (!$findtok(%ts.channels,$chan,1,44)) { halt }
  ; command help
  if $1- == !ts { msg # 7[TS3] 3TeamSpeak Commands: 9!TS Users, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. }
  if ($1 == !ts) && ($2 == help) {
    if $3 == users { msg # 7[TS3] 9!TS Users - 11Displays information about the currently connected users. }
    elseif $3 == info { msg # 7[TS3] 9!TS Info - 11Lists basic information about the TeamSpeak Server }
    elseif $3 == channels { msg # 7[TS3] 9!TS Channels - 11Displays all channels and the number of users in them. }
    elseif $3 == msg { msg # 7[TS3] 9!TS Msg <message> - 11Sends a message to the server }
    elseif $3 == PM { msg # 7[TS3] 9!TS PM <user> <message> - 11Sends a private message to an user }
    elseif $3 == poke { msg # 7[TS3] 9!TS Poke <user> <message> - 11Pokes an user with the specified message (if any). }
    elseif $3 == kick { msg # 7[TS3] 9!TS Kick <user> <reason> - 11Kicks an user from the server. }
    elseif $3 == ban { msg # 7[TS3] 9!TS Ban <user> <reason> - 11Bans an user from the server. }
    elseif $3 == version { msg # 7[TS3] 9!TS Version - 11Displays information about the script and its author. }
    elseif (!$3) { msg # 7[TS3] 3TeamSpeak Commands: 9!TS Users, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. }
    else { msg # 7[TS3] 4Unknown command. 3TeamSpeak Commands: 9!TS Users, Channels, Kick, Ban, Msg, PM, Poke, Info, Version - 11"!TS help [command]" for more information. }
  }
  ; commands
  if $1-2 == !ts connect && ($nick ishop # || $nick isop #)  { ts.connect } 
  elseif $1 == !ts && $2 != connect && !$sock(ts3) { msg # 7[TS3] 4Error: 11Not connected to the TeamSpeak server, connecting to server.. | ts.connect }
  if ($1-2 == !ts info) { ts3info $chan }
  if ($1-2 == !ts users) { ts3users $chan }
  if ($1-2 == !ts version) { ts3version $chan }
  if ($1-2 == !ts channels) { ts3channels $chan }
  if ($1-2 == !ts msg) { ts3msg $nick $+ ; $+ $3- }
  if ($1-2 == !ts poke) { ts3poke $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
  if ($1-2 == !ts ban) {
    if ($nick !ishop $chan) && ($nick !isop $chan) { msg $chan 7[TS3] 9[Ban] 11You lack the required permissions to use this command | HALT }
    else { ts3ban $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
  }
  if ($1-2 == !ts kick) {
    if ($nick !ishop $chan) && ($nick !isop $chan) { msg $chan 7[TS3] 9[Kick] 11You lack the required permissions to use this command | HALT }
    else { 
      if (%ts-admin != $null) {
      msg %ts-admin 7[TS3] 9[Akick]3 $3 has been kicked by $nick $+ @IRC for: $4- $+ . }
    ts3kick $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan }
  }
  if ($1-2 == !ts pm) {
    ts3pm $3 $+ ; $+ $4- $+ ; $+ $nick $+ ; $+ $chan
  }
}

;=======================================
;===== Reading & Responding or Relaying

on *:sockread:ts3: {
  ; puts the information recieved from the ts sever into %tsl, and then throws it into $*
  var %tsl | sockread -n %tsl | tokenize 32 %tsl
  var %tsl2 = $right(%tsl, -1)
  if %tsl == TS3 {
    .timertsconfail off 
    msg %ts.channels 7[TS3] Connection Establised...Logging in as a server admin.
    set %ts.act login
    ts3.d login client_login_name= $+ %ts.slogin client_login_password= $+ %ts.spass
  }
  if (error id=*msg=* iswm %tsl2) && (%tsl2 != error id=0 msg=ok) {
    if (%ts.act == ban) {
      msg %ts.banchan 7[TS3] 9[Ban] The bot does not have the permissions needed to ban the client specified. Reasons for this could be:
      msg %ts.banchan 7[TS3] 9[Ban] 1) The client you are trying to ban is a serveradmin, or is in a group with the permission "b_client_ignore_bans" granted.
      msg %ts.banchan 7[TS3] 9[Ban] 2) The bot does not have the permissions to ban. Please check if the bot is in the "Admin ServerQuery" group. 
      unset %ts.act
      unset %ts.banchan
    }
    elseif (%ts.act == kick) {
      msg %ts.kickchan 7[TS3] 9[Kick] The bot does not have the permissions needed to kick the client specified. Reasons for this could be:
      msg %ts.kickchan 7[TS3] 9[Kick] 1) The bot does not have the permissions to kick. Please check if the bot is in the "Admin ServerQuery" group. 
      unset %ts.act
      unset %ts.kickchan
    }
    elseif (%ts.act == login) {
      msg %ts.channels 7[TS3] Unable to login on the server, are you sure you have entered the username/password correctly?
      ts.sockclose silent
      unset %ts.act
    }
    elseif (%ts.act == sid) {
      msg %ts.channels 7[TS3] Unable to find a server. Reasons for this could be:
      msg %ts.channels 7[TS3] 1) The bot does not have the required permissions to request the server ID. Please doublecheck the permissions the bot has on the TS3 server.
      msg %ts.channels 7[TS3] 2) The server port you have entered in the script is incorrect. 
      ts.sockclose silent
      unset %ts.act
    }
    else {
      msg %ts.channels 7[TS3] Permission error! ( $+ $ts.clean(%tsl2) $+ )
      msg %ts.channels 7[TS3] Please check if the bot has the required permissions to take the action that's needed.
      msg %ts.channels 7[TS3] If you don't know what could be causing this error message, please contact the author of the script. (!TS Version)
    }
  }
  if (cid=*pid=*channel_order=*channel_name=*total_clients=*channel_needed_subscribe_power=* iswm %tsl2) {
    var %ts.chanlist = %tsl2
    var %totalchannels = $gettok(%ts.chanlist, 0, 124) 
    if (%totalchannels == 0) { HALT }
    if ($hget(ts3chan)) { hfree ts3chan }
    hmake ts3chan 10
    var %a = 1
    while (%a <= %totalchannels) {
      var %rawline = $gettok(%ts.chanlist, %a $+ , 124)
      tokenize 32 %rawline
      var %cid = $gettok($1, 2, 61)
      var %pid = $gettok($2, 2, 61)
      var %chan = $gettok($4, 2, 61)
      var %totclients = $gettok($5, 2, 61)
      hadd ts3chan %cid %chan $+ ; $+ %totclients
      if (%ts.displaychanlist == 1) {
        msg %ts.chanchan 7[TS3] $iif(%pid != 0, 9--, 3) $+ $ts.clean(%chan) $iif(%totclients != 0, 11[ $+ %totclients $iif(%totclients == 1, client, clients) $+ ])
      }
      inc %a
    } 
    unset %ts.chanchan
    unset %ts.displaychanlist
  }
  if (clid=*cid=*client_database_id=*client_nickname=* iswm %tsl2) && (%ts.getclientlist == 1) {
    set %ts.clients %tsl2
    var %totalclients = $gettok(%ts.clients, 0, 124) 
    if (%totalclients == 0) { HALT }
    hdel -w ts3 *
    var %a = 1
    while (%a <= %totalclients) {
      var %rawline = $gettok(%ts.clients, %a $+ , 124)
      tokenize 32 %rawline
      var %clid = $gettok($1, 2, 61)
      var %cid = $gettok($2, 2, 61)
      var %ts3nick = $gettok($4, 2, 61)
      var %away = $gettok($6, 2, 61)
      var %awaymessage = $iif($gettok($7, 2, 61), $gettok($7, 2, 61))
      var %connectionmethod = $gettok($5, 2, 61)
      if (%connectionmethod != 1) {
        var %ts.online = $addtok(%ts.online, %ts3nick, 44)
        hadd ts3 %ts3nick $+ ; $+ %clid cid= $+ %cid $+ ;away= $+ %away $+ ;awaymessage= $+ %awaymessage
      }
      inc %a
    } 
    unset %ts.clients
    unset %ts.getclientlist
    if (%ingame.show == 1) {
      if ($len(%ts.online) > 150) { var %ts.online = $left(%ts.online, 147) $+ ... }
      sendexo msg Currently online on TS3: %ts.online
      sendexo msg Join us on TS3 @ ts.RenCorner.com - Port: 9987 (Default)
      unset %ingame.show
    }
    if (%ts.showclientlist == 1) {
      ts.displaylist
      unset %ts.showclientlist
    }
  }
  if ((server_id=* iswm %tsl2) && (%ts.act == sid)) {
    var %sid = $gettok(%tsl2, 2, 61)
    msg %ts.channels 7[TS3] Selecting server on ID %sid with port %ts.sport $+ ...
    set %ts.act use
    ts3.d use sid= $+ %sid
  }
  if (virtualserver_unique_identifier=*virtualserver_name=*virtualserver_welcomemessage=*virtualserver_platform=*virtualserver_version=*virtualserver_maxclients=* iswm %tsl2) {
    var %name = $ts.clean($gettok($2, 2, 61))
    var %platform = $ts.clean($gettok($4, 2, 61))
    var %version = $ts.clean($gettok($5, 2, 61))
    var %maxclients = $gettok($6, 2, 61)
    var %currclients = $gettok($8, 2, 61)
    var %channels = $gettok($9, 2, 61)
    msg %ts.infochan 7[TS3] 9[Name] 03 $+ %name
    msg %ts.infochan 7[TS3] 9[IP/Port] 03 $+ %ts.ip.public $+ : $+ %ts.sport
    msg %ts.infochan 7[TS3] 9[Clients] 03[ $+ %currclients $+ / $+ %maxclients $+ ] - 11Type !TS Users for more information
    msg %ts.infochan 7[TS3] 9[Channels] 03 $+ %channels channels - 11Type !TS Channels for more information
    msg %ts.infochan 7[TS3] 9[Version] 03 $+ %platform %version
    unset %ts.infochan
  }
  if (notifytextmessage* iswm %tsl2) {
    var %targetmode = $gettok($2, 2, 61)
    if (%targetmode == 3) {
      var %msg1 = $ts.clean($right($3, -4))
      var %msg = $iif(* iswm %msg1, $right(%msg1, -15), %msg1)
      var %messager = $ts.clean($gettok($5, 2, 61))
      msg %ts.channels 7[TS3] 09[Message] 11 $+ %messager $+ : 03 $+ %msg $+ 
      if (%ts-admin != $null) {
        if ($readini(idiplog.ini,tsip,%messager) == $null) && (%messager != server) {
          msg %ts-admin 7[TS3] 09[Message] 11 $+ %messager $+ : 03 $+ %msg $+  | halt
        }
        if (%messager == server) { msg %ts-admin 7[TS3] 09[Message] 11 $+ %messager $+ : 03 $+ %msg $+ 
        }
        else {
          msg %ts-admin 7[TS3] 09[Message] 11 $+ %messager $+ $chr(40) $+ $readini(idiplog.ini, tsip, %messager) $+ $chr(41) $+ : 03 $+ %msg $+ 
        }
      }
    }
  }
  if (notifyclientleftview* iswm %tsl2) {
    var %clid = $gettok($6, 2, 61)
    var %leavemsg = $ts.clean($gettok($5, 2, 61))
    var %hashname = $hfind(ts3, *; $+ %clid, 1, w)
    if (!%hashname) { HALT }
    var %leavenick = $gettok(%hashname, 1, 59)
    msg %ts.channels 7[TS3] 9[Player Left] 11 $+ %leavenick -3 Quitmessage: %leavemsg $+ 
    hdel ts3 %hashname
    set %ts.getclientlist 1
    ts3.d clientlist -away
    if (%tsdirectory != $null) && (%ts-admin != $null) {
      ls1
      set %lines2 $lines(%lss)
      msg %ts-admin 7[TS3]9 $html2chr($gettok($read(%lss,%lines2),5, 124))

    }
  }
  if (*notifycliententerview* iswm %tsl2) {
    var %clid = $gettok($5, 2, 61)
    var %identifier = $gettok($6, 2, 61)
    var %clnick = $ts.clean($gettok($7, 2, 61))
    var %inputhardware = $gettok($11, 2, 61)
    var %outputhardware = $gettok($12, 2, 61)
    if ((%identifier != ServerQuery) && (%inputhardware == 1) && (%outputhardware == 1)) {
      hadd ts3 %clnick $+ ; $+ %clid
      msg %ts.channels 7[TS3] 9[Player Join] 11 $+ %clnick
      set %ts.getclientlist 1
      ts3.d clientlist -away
      if (%tsdirectory != $null) && (%ts-admin != $null) {
        ls1
        set %lines2 $lines(%lss)
        set %tcpportts $chr(58) $+ $gettok($html2chr($gettok($read(%lss,%lines2),5, 124)),3,58)
        msg %ts-admin 7[TS3]9 $remove($html2chr($gettok($read(%lss,%lines2),5, 124)),%tcpportts)
        set %lss22 $gettok($read(%lss,%lines2),5, 124)
        if ($chr(32) isin $gettok(%lss22,2,39)) {
          writeini idlog.ini idlog $replace($gettok(%lss22,2,39),$chr(32),_) $remove($gettok(%lss22,2,40),id:,$chr(41),%tcpportts)
          writeini idiplog.ini tsip $Replace($gettok(%lss22,2,39),$chr(32),_) $remove($gettok(%lss22,2,41),from,$chr(32),%tcpportts)
        }
        else {
          writeini idlog.ini idlog $gettok(%lss22,2,39) $remove($gettok(%lss22,2,40),id:,$chr(41),%tcpportts)
          writeini idiplog.ini tsip $gettok(%lss22,2,39) $remove($gettok(%lss22,2,41),from,$chr(32),%tcpportts)
        }
      }
    }
  }
  ; The following is triggered when "OK" is sent to the server, based on %ts.act, it reacts accordingly
  elseif (%tsl2 == error id=0 msg=ok) {
    if %ts.act == use {
      msg %ts.channels 7[TS3] TS3 Virtual Server selected successfully, ready for duty.
      .timertspingout 1 %ts.timeout ts.sockclose
      set %ts.act getsid
      ts3.d servernotifyregister event=server
      ts3.d servernotifyregister event=textserver
      ts3.d clientupdate client_nickname= $+ $me
      if ($hget(ts3chan)) { hfree ts3chan }
      if (!$hget(ts3chan)) { hmake ts3chan 10 }
      if ($hget(ts3)) { hfree ts3 }
      if (!$hget(ts3)) { hmake ts3 10 }
      set %ts.getclientlist 1
      ts3.d clientlist -away
      .timertscheckok 0 5 ts.checkok
    }
    elseif %ts.act == ban {
      msg %ts.banchan 7[TS3] 9[Ban] 3The client has been banned successfully.
      unset %ts.act
      unset %ts.banchan
    }
    elseif %ts.act == kick {
      msg %ts.kickchan 7[TS3] 9[Kick] 3The client has been kicked successfully.
      unset %ts.act
      unset %ts.kickchan
    }
    elseif %ts.act == login {
      msg %ts.channels 7[TS3] Logged in successfully, Searching for server id...
      set %ts.act sid
      ts3.d serveridgetbyport virtualserver_port= $+ %ts.sport
    }
    elseif $gettok(%ts.act,1,32) == pl {
      unset %ts.act
    }
    elseif $gettok(%ts.act,1,32) == bl {
      unset %ts.act
    }
    elseif %ts.checkok == check { .timertspingout 1 %ts.timeout ts.sockclose | unset %ts.checkok }
  }
}

; ***Checks if the server is still responding every 5 seconds***
alias ts.checkok {
  ts3.d whoami
  set %ts.checkok check
}

; activates if the connection is lost
on *:sockclose:ts3: { ts.sockclose }
; activates when a socket times out, kills the timers
alias ts.sockclose {
  if !$1 {
    sockclose ts3
    msg %ts.channels 7[TS3] TS Error: Socket timed out.
    .timergettslogs off
    .timertscheckok off
  }
  elseif $1 == cc {
    msg %ts.channels 7[TS3] TeamSpeak failed to connect! Reasons for this could be:
    msg %ts.channels 7[TS3] 1) The server is offline 
    msg %ts.channels 7[TS3] 2) The IP or Query Port you have entered is incorrect.
    .timergettslogs off
    .timertscheckok off
    sockclose ts3
    .timertspingout off
  }
  elseif $1 == silent { 
    .timergettslogs off
    .timertscheckok off
    .timertspingout off
    sockclose ts3
  }
}

Comments

Sign in to comment.
dronez4   -  Feb 07, 2014

Heres a lil bit more about what it does.

(22:38:12) <&RCBOT> 7[TS3]9 client connected 'dronez4'(id:302) from 5.68.92.27
(23:41:27) <&RCBOT> 7[TS3]9 client disconnected 'dronez4'(id:302) reason 'reasonmsg=leaving'

(23:42:06) !ts ip dronez4
(23:42:07) <&RCBOT> 7[TS3]9 Last known IP of dronez4: 5.68.92.27
(23:43:09) !ts id dronez4
(23:43:09) <&RCBOT> 7[TS3]9 Last known ID of dronez4: 302 from 5.68.92.27

(23:44:10) <&RCBOT> 7[TS3] 09[Message] 11dronez4(5.68.92.27): 03echo

 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.