All pastes #262061 Raw Edit

Something

public text v1 · immutable
#262061 ·published 2006-11-30 03:23 UTC
rendered paste body
menu channel { 
  Translator:/dialog -ma Translater_Dialog Translater_dialog 
} 
on *:DIALOG:Translater_dialog:sclick:4,1:{ 
  if ($did == 4) { /set %translate-from $did(4).seltext } 
  if ($did == 1) { /set %translate-too $did(1).seltext  } 
} 

on *:DIALOG:Translater_dialog:init:*:{ 
  /did -a Translater_dialog 4 French 
  /did -a Translater_dialog 4 Spanish 
  /did -a Translater_dialog 4 German 
  /did -a Translater_dialog 4 Italian 
  /did -a Translater_dialog 4 English 
  /did -a Translater_dialog 1 French 
  /did -a Translater_dialog 1 Spanish 
  /did -a Translater_dialog 1 German 
  /did -a Translater_dialog 1 Italian 
  /did -a Translater_dialog 1 English 
} 

alias translate { /dialog -ma Translater_dialog Translater_dialog } 

on *:DIALOG:Translater_dialog:edit:8:{ /set %translate-text $replace($did(8),$chr(32),$+(%,2,0)) } 

on *:DIALOG:Translater_dialog:close:*:{ translate-text } 

dialog Translater_dialog { 
  title "Translater_dialog" 
  size -1 -1 188 141 
  option dbu 
  list 1, 124 28 50 50, sort size 
  button "Translate", 2, 12 123 78 12, ok 
  button "Cancel", 3, 99 123 75 12, cancel 
  list 4, 58 28 50 50, sort size 
  text "Translate from?", 5, 60 19 45 8 
  text "Translate too?", 6, 128 20 42 8 
  box "Translater", 7, 5 5 181 133 
  edit "", 8, 36 97 50 10, autohs 
  box "Text To Translate", 9, 24 88 72 26 
  box "Languges", 10, 55 11 129 70 
  text "Welcome to the translater dialog please select a languge to translate from and a languge to translate too then enter your text to translate.", 11, 10 22 42 58 
} 

alias -l translate-text { 
  sockopen lang ets.freetranslation.com 80 
} 
on *:SOCKOPEN:lang:{ 
  sockwrite -n $sockname GET /?srcText= $+ %translate-text $+ &mode=html&template=results_en-us.htm&sequence=core&language= $+ %translate-from $+ $+(%,2,F) $+ %translate-too HTTP/1.1 
  sockwrite -n $sockname Host: ets.freetranslation.com $+ $crlf $+ $crlf 
} 
on *:SOCKREAD:lang:{ 
  if ($sockerr) { /echo -a Sorry $nick There was a problem connecting to the site, try again soon. | { /halt } } 
  else { 
    var %outcome-looks-? 
    sockread -f %outcome-looks-? 
    if (*textarea name="dsttext" cols="40" rows="6"* iswm %outcome-looks-?) { /dialog -ma Translater_Dialog_ Translater_Dialog_ | /did -a Translater_dialog_ 1 $html-just-ditch-it($remove(%outcome-looks-?,$chr(9))) | /unset %translate* %%outcome-looks-? | { /halt } } 
    if ($sockerr) { /echo -a Sorry $nick There was a problem connecting to the site, try again soon. } 
  } 
} 

alias -l html-just-ditch-it { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
} 

dialog Translater_Dialog_ { 
  title "Translater Dialog" 
  size -1 -1 169 88 
  option dbu 
  text "Here is the Translated text you wanted.", 2, 17 16 144 16 
  box "Finished", 3, 8 5 157 79 
  button "Close", 4, 13 69 74 12, cancel 
  button "Translate something else", 5, 91 69 67 12, ok 
  combo 1, 18 34 132 34, size 
} 

on *:DIALOG:Translater_Dialog_:sclick:5:{ /.timer 1 1 /dialog -ma Translater_Dialog Translater_Dialog } 

on $*:text:/[!@`/.]ircmode*/:#: { 
  set %send $iif($left($1,1) == @,msg $chan,.notice $nick) 
  if (!$2) { %send Type !ircmode mode (case sensative). } 
  if ($2 == help) { %send The modes for NickNames are: vhoaq 
  %send The modes for Channels are: bceifiklmnprstzACGMKLNOQRSTVU~ } 
  elseif ($2 === v) { %send v = gives voice to the user (may talk if chan is +m or +M) (%) } 
  elseif ($2 === h) { %send h = gives halfop status to the user (limited op access) } 
  elseif ($2 === o) { %send o = gives operator status to the user } 
  elseif ($2 === a) { %send a = gives channel admin to the user (~) } 
  elseif ($2 === q) { %send q = gives owner status to the user (~) } 
  elseif ($2 === b) { %send b = bans the nick!ident@host from the channel (%) } 
  elseif ($2 === c) { %send c = block messages containing mirc color codes (@) } 
  elseif ($2 === e) { %send e = overrides a ban for matching users (%) } 
  elseif ($2 === i) { %send i = overrides +i for matching users (%) } 
  elseif ($2 === f) { %send f = flood protection (for more info see /helpop chmodef) (@) } 
  elseif ($2 === i) { %send i = a user must be invited to join the channel (%) } 
  elseif ($2 === k) { %send k = users must specify to join (%) } 
  elseif ($2 === l) { %send l = channel may hold at most of users (@) } 
  elseif ($2 === m) { %send m = moderated channel (only +vhoaq users may speak) (%) } 
  elseif ($2 === n) { %send n = users outside the channel can not send privmsgs to the channel (%) } 
  elseif ($2 === p) { %send p = private channel (@) } 
  elseif ($2 === r) { %send r = the channel is registered (settable by services only) } 
  elseif ($2 === s) { %send s = secret channel (@) } 
  elseif ($2 === t) { %send t = only +hoaq may change the topic (%) } 
  elseif ($2 === z) { %send z = only clients on a secure connection (ssl) can join (@) } 
  elseif ($2 === A) { %send A = server/net admin only channel (settable by admins) } 
  elseif ($2 === C) { %send C = no ctcps allowed in the channel (@) } 
  elseif ($2 === G) { %send G = filters out all bad words in messages with (@) } 
  elseif ($2 === M) { %send M = must be using a registered nick (+r), or have voice access to talk (@) } 
  elseif ($2 === K) { %send K = /knock is not allowed (@) } 
  elseif ($2 === L) { %send L = channel link (~) } 
  elseif ($2 === N) { %send N = no nickname changes are permitted in the channel (@) } 
  elseif ($2 === O) { %send O = irc operator only channel (settable by ircops) } 
  elseif ($2 === Q) { %send Q = no kicks allowed (@) } 
  elseif ($2 === R) { %send R = only registered (+r) users may join the channel (@) } 
  elseif ($2 === S) { %send S = strips mirc color codes (@) } 
  elseif ($2 === T) { %send T = no notices allowed in the channel (@) } 
  elseif ($2 === V) { %send V = /invite is not allowed (@) } 
  elseif ($2 === U) { %send U = auditorium mode (/names and /who #channel only show channel ops) (~) } 
  elseif ($2 === ~) { %send (~) = Requires owner (+q), (@) = Requires ops or above (+oaq), (%) = Requires halfops or above (+oaqh) } 
  else { %send $2 is not a mode in SwiftIRC. } 
} 
ON $*:TEXT:/^[!@.]info$/Si:#:{ 
  VAR %i = 1 
  WHILE (%i <= $chan(0)) { 
    VAR %c = $chan(%i), %channels = $addtok(%channels,$+($iif($me isop %c,@),$iif($me ishop %c,%),$iif($me isvoice %c,+),%c),32) 
    INC %i 
  } 
  $iif($left($1,1) == @,msg $chan,.notice $nick) 4I'm currently on: %channels 
}
on $*:text:/^[!@]price(s|check)*/Si:#: { 
  if ( !$2 ) { notice $nick Sorry you must specify what to search for - !price <item> } 
  else { 
    /var %number 1 
    while ($sock(price.socket. $+ %number)) { /inc %number } 
    if (!* iswm $1) { /set %price.displaystyle. [ $+ [ %number ] ] private } 
    /set %price.item. [ $+ [ %number ] ] $2- 
    /set %price.nick. [ $+ [ %number ] ] $nick 
    /set %price.chan. [ $+ [ %number ] ] $chan 
    /sockopen $+(price.socket.,%number) zybez.net 80 
  } ;Closes Else 
} ;Ends the !pricecheck section 

on *:sockopen:price.socket.*:{ 
  sockwrite -nt $sockname GET /priceguide.php?search_terms= $+ $replace(%price.item. [ $+ [ $right($SockName,-13) ] ] ,$chr(32),$chr(43)) $+ &search_area=1&price_low=&price_high=&member=1 HTTP/1.1 
  sockwrite -nt $sockname Host: zybez.net 
  sockwrite -nt $sockname $crlf $crlf 
} 

on *:sockread:price.socket.*:{ 
  var %i $right($sockname,-13) 
  if ($sockerr) { /notice %price.nick. [ $+ [ %i ] ] Sorry but an error occured while searching for %price.item. [ $+ [ %i ] ] | halt } 
  else { 
    var %temptext 
    sockread %temptext 
    ;Once bot gets the Item + Price which is represented my %readnextline == 2, it runs this to display the results for the user then restarts the whole proccess. 

    if (%readnextline == 2) { 
      /inc %price.displayed. [ $+ [ %i ] ] 
      /var %price.displayprice $htmlfree(%temptext) 
      /var %message 12,15 %price.displayitem. [ $+ [ %i ] ] - %price.displayprice prices from http://www.zybez.net  
      /unset %readnextline 

      ; Limits how many items are displayed before it stops reading. Prevents the bot from flooding. 
      if ( %price.displayed. [ $+ [ %i ] ] < 6 ) { 
        if ( %price.displaystyle. [ $+ [ %i ] ] == private ) { /notice %price.nick. [ $+ [ %i ] ] %message } 
        else { /msg %price.chan. [ $+ [ %i ] ] %message } 
      } ; Closes if statement - if ( %price.displayed. [ $+ [ %i ] ] < 6 ) 
      else { /notice %price.nick. [ $+ [ %i ] ] Sorry but your search for " $+ %price.item. [ $+ [ %i ] ] $+ " was not specific enough. Please narrow your searh down, ie: Rune --> Rune Platelegs | /sockclose $+(price.socket.,%i) | /unset %price.*. [ $+ [ %i ] ] } 
    } ; Closes if statement - if (%readnextline == 2) 

    if (%readnextline == 1) { /set %price.displayitem. [ $+ [ %i ] ] $htmlfree(%temptext) | /set %readnextline 2 } 
    if ( *<img src="/img/member.gif"* iswm %temptext || <td class="tablebottom"><!-- Blank --></td> isin %temptext || <!-- <td class="tablebottom">Zybez is screwing up our parser because we don't credit them. ^_^</td> isin %temptext || <td class="tablebottom">http://www.zybez.net</td> --> isin %temptext) { /set %readnextline 1 } 
    if (*Your search did not * iswm %temptext) { /notice %price.nick. [ $+ [ %i ] ] Sorry I did not find " $+ %price.item. [ $+ [ %i ] ] $+ " in the Zybez database. Please make sure you spelled everything correctly and the item you are searching for exists in Runescape. } 
  } ; Closes else 
} ;Ends the sockread section 

on *:sockclose:price.socket.*:{ /unset %price.*. [ $+ [ $right($SockName,-13) ] ] } 

alias -l htmlfree { 
  ; Cleans all html from a file 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
} ;Ends the html cleaner alias