This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Needs to convert this to tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
E
Eyecu
Voice
Posts: 1
Joined: Wed Feb 29, 2012 3:32 pm

Needs to convert this to tcl

Post by Eyecu »

As the title says i need to convert this script from mirc language to tcl, but i have no clue how to right tcl. Before anyone says just use an rss feed reader, it wont work in this case as some of the sites in the list don't use rss or atom feeds in any way :(. I appreciate any help with this.

Code: Select all

on *:Join:*: { 
  if ($nick == $me) { 
    .timer.newsck 0 15 newsck 
    .timer.sf 0 20 soulfly
    .timer.evo 0 22 evolution
    .timer.chain 0 18 chainz
    .timer.hawkee 0 15 hawkee
    .timer.mirc 0 27 mircforum
    .timer.rumbaar 0 32 rumbaar
    .timer.giveaway 0 3660 giveaway
  } 
}
; Menu =====================================================================================
menu channel {
  Feeder
  .$iif(%Feed.chainnews. [ $+ [ $active ] ] == on,$style(1)) ChainzScripts: $iif(%Feed.chainnews. [ $+ [ $active ] ] == on,unset %Feed.chainnews. [ $+ [ $active ] ],set %Feed.chainnews. [ $+ [ $active ] ] on)
  .$iif(%Feed.evonews. [ $+ [ $active ] ] == on,$style(1)) Evolution: $iif(%Feed.evonews. [ $+ [ $active ] ] == on,unset %Feed.evonews. [ $+ [ $active ] ],set %Feed.evonews. [ $+ [ $active ] ] on)
  .$iif(%Feed.hknews. [ $+ [ $active ] ] == on,$style(1)) Hawkee: $iif(%Feed.hknews. [ $+ [ $active ] ] == on,unset %Feed.hknews. [ $+ [ $active ] ],set %Feed.hknews. [ $+ [ $active ] ] on)
  .$iif(%Feed.mircnews. [ $+ [ $active ] ] == on,$style(1)) mIRC: $iif(%Feed.mircnews. [ $+ [ $active ] ] == on,unset %Feed.mircnews. [ $+ [ $active ] ],set %Feed.mircnews. [ $+ [ $active ] ] on)
  .$iif(%Feed.rumbaarnews. [ $+ [ $active ] ] == on,$style(1)) Rumbaar: $iif(%Feed.rumbaarnews. [ $+ [ $active ] ] == on,unset %Feed.rumbaarnews. [ $+ [ $active ] ],set %Feed.rumbaarnews. [ $+ [ $active ] ] on)
  .$iif(%Feed.sfnews. [ $+ [ $active ] ] == on,$style(1)) SoulFly: $iif(%Feed.sfnews. [ $+ [ $active ] ] == on,unset %Feed.sfnews. [ $+ [ $active ] ],set %Feed.sfnews. [ $+ [ $active ] ] on)
  .$iif(%Feed.tgnews. [ $+ [ $active ] ] == on,$style(1)) TechGear: $iif(%Feed.tgnews. [ $+ [ $active ] ] == on,unset %Feed.tgnews. [ $+ [ $active ] ],set %Feed.tgnews. [ $+ [ $active ] ] on)
  .-
  .Add All $chan : {
    set %Feed.chainnews. [ $+ [ $active ] ] on
    set %Feed.evonews. [ $+ [ $active ] ] on
    set %Feed.hknews. [ $+ [ $active ] ] on
    set %Feed.mircnews. [ $+ [ $active ] ] on
    set %Feed.rumbaarnews. [ $+ [ $active ] ] on
    set %Feed.sfnews. [ $+ [ $active ] ] on
    set %Feed.tgnews. [ $+ [ $active ] ] on
  }
  .Remove All $chan : unset %Feed.*. [ $+ [ $active ] ]
  .-
  .Clear Saved Topics: unset %Topic.*
}  

; Aliases ==================================================================================
alias striphtml {
  if (!$isid) || (!$1) return
  var %H = $1 , %T = $regsub(%H,/(<[^>]+>)/g,,%H)
  if ($chr(38) isin %H) {
    set %H $replacecs(%H,&,&,"," ,<,< ,>,> ,&,& , ,$iif($prop,$chr($prop),$chr(32)) ,£,£ ,§,$chr(36) ,¨,¨ ,«,« ,»,» ,ß,ß, Ñ,Ñ ,ñ,ñ,',')
    set %H $replacecs(%H,À,À ,Á,Á ,Â, ,Ã,à ,Ä,Ä ,Å,Å ,Æ,Æ ,à,à ,á,á ,â,â ,ã,ã ,ä,ä ,å,å ,æ,æ)
    set %H $replacecs(%H,È,È,É,É,Ê,Ê,Ë,Ë,è,è,é,é,ê,ê,ë,ë,Ì,Ì,Í,Í,Î,Î,Ï,Ï,ì,ì,í,í,î,î)
    set %H $replacecs(%H,ï,ï,Ò,Ò,Ó,Ó,Ô,Ô,Õ,Õ,Ö,Ö,Ø,Ø,ò,ò,ó,ó,ô,ô,õ,õ,ö,ö,ø,ø,Ù,Ù,Ú,Ú,Û,Û,Ü,Ü,Ý,Ý,ù,ù,ú,ú,û,û,ü,ü,ý,ý,ÿ,ÿ)
  }
  return %H
}
alias turl {
  var %s tinyURL. $+ $ticks
  sockopen %s tinyurl.com 80
  sockmark %s $1 $2 $4 $5 $3
}
on *:sockopen:TinyURL.*: { sockwrite -tn $sockname $+(GET /api-create.php?url= $+ $gettok($sock($sockname).mark,3,32) HTTP/1.1,$crlf,Host: tinyurl.com,$crlf,$str($crlf,2)) }
on *:sockread:TinyURL.*:{
  var %r | sockread %r
  if ($left(%r,7) == HTTP://) {
    var %f 1
    while ($chan(%f)) { 
      var %g $gettok($sock($sockname).mark,2,32) $+ . $+ $chan(%f)
      if (%FEED. [ $+ [ %g ] ] == on) && (($me isop $chan(%f)) || ($me ishop $chan(%f))) { 
        msg $chan(%f) $gettok($sock($sockname).mark,1,32) Topic Update: $striphtml($gettok($sock($sockname).mark,5-,32)) - %r $iif($gettok($sock($sockname).mark,4,32) != n/a,- by $striphtml($gettok($sock($sockname).mark,4,32))) 
      }
      inc %f
    }
  }
}
; Chainscriptz ===============================================================================
alias chainz {
  if ($status != connected) { halt }
  sockclose chainforum | sockopen chainforum chainscriptz.net 80
}
on *:sockopen:chainforum: { 
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /chainposts.php HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
  sockwrite -n $sockname Host: chainscriptz.net
  sockwrite -n $sockname $crlf
}
on *:sockread:chainforum: {
  if ($sockerr) { echo -a Error. | halt }
  var %chain | sockread %chain
  if (*Chainscriptz Latest Posts* iswm %chain) {
    tokenize 165 %chain
    if ($3 != %Topic.CHAIN) && (ERROR--CAN'T CONNECT TO SERVER !isin $2-) && ($2 != $null) { 
      if ($regex($3,/\#entry(.*?)$/)) { set %chainnewsid $regml(1) }
      ;;$turl(site,feed,title,url,by)
      $turl(Chainscriptz,chainnews,$2,$3,$gettok($4,2,32))
      set %Topic.CHAIN $3
      unset %chainnewsid
      sockclose chainforum
    }
  }
}

;Evolution ====================================================================================
alias evolution {
  if ($status != connected) { halt }
  sockclose evoforum
  sockopen evoforum evolutionscriptz.com 80
  if (%Topic.EVO == $null) { set %Topic.EVO on }
  set %evo.check 1
}
on *:sockopen:evoforum: { 
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /feed.php HTTP/1.1
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
  sockwrite -n $sockname Host: evolutionscriptz.com
  sockwrite -n $sockname $crlf
}
on *:sockread:evoforum: {
  if ($sockerr > 0) return
  var %evo
  sockread %evo
  if (%chain == 0) || (%evo.check > 4) { 
    sockclose $sockname 
    if (%evo.linktemp != $null) && (%evo.linktemp != on) && (%evo.linktemp != %Topic.EVO) {
      set %Topic.EVO %evo.linktemp
      ;;$turl(site,feed,title,url,by)
      $turl(EvolutionScriptz,evonews,$striphtml(%evo.title),$replace(%evo.linktemp,&,&),n/a)

    }
    unset %evo.* 
  }
  else {
    if (%evo.check == 1) var %evor = /<entry>/ig
    if (%evo.check == 2) var %evor = /<author><name><\!\[CDATA\[(.*)\]\]><\/name><\/author>/ig
    if (%evo.check == 3) var %evor = /<link href="(.*)"\/>/ig
    if (%evo.check == 4) var %evor = /<title type="html"><\!\[CDATA\[(.*)\]\]><\/title>/ig
    if ($regex(evoforum, %evo, %evor) > 0) {
      if (%evo.check == 2) { set %evo.title by $regml(evoforum,1) }
      if (%evo.check == 3) { set %evo.linktemp $regml(evoforum,1) }
      if (%evo.check == 4) { set %evo.title $regml(evoforum,1) %evo.title }
      inc %evo.check
    }
  }
}

; Hawkee ======================================================================================
alias hawkee {
  if ($status != connected) { halt }
  sockclose hawkeeforum
  sockopen hawkeeforum hawkee.com 80
  if (%Topic.HAWKEE == $null) { set %Topic.HAWKEE on }
  set %hawkee.check 1
}
on *:sockopen:hawkeeforum: { 
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /comment.rss.php HTTP/1.1
  sockwrite -n $sockname Host: www.hawkee.com
  sockwrite -n $sockname $crlf
}
on *:sockread:hawkeeforum: {
  if ($sockerr > 0) return
  var %hawkee
  sockread %hawkee
  if (%hawkee == 0) || (%hawkee.check > 3) { 
    sockclose $sockname 
    if (%hawkee.linktemp != $null) && (%hawkee.linktemp != on) && (%hawkee.linktemp != %Topic.HAWKEE) {
      set %Topic.HAWKEE %hawkee.linktemp
      $turl(Hawkee,hknews,$striphtml(%hawkee.title),$replace(%hawkee.linktemp,&,&),n/a)
    }
    unset %hawkee.* 
  }
  else {
    if (%hawkee.check == 1) var %hawkeer = /<item>/ig
    if (%hawkee.check == 2) var %hawkeer = /<title>(.*)<\/title>/ig
    if (%hawkee.check == 3) var %hawkeer = /<link>(.*)<\/link>/ig
    if ($regex(hawkeeforum, %hawkee, %hawkeer) > 0) {
      if (%hawkee.check == 2) set %hawkee.title $regml(hawkeeforum,1)
      if (%hawkee.check == 3) set %hawkee.linktemp $regml(hawkeeforum,1)
      inc %hawkee.check
    }
  }
}

; mIRC ========================================================================================
alias mircforum {
  if ($status != connected) { halt }
  sockclose mircforum
  sockopen mircforum forums.mirc.com 80
  if (%Topic.MIRC == $null) { set %Topic.MIRC on }
  set %mirc.check 1
}

on *:sockopen:mircforum: { 
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /ubbthreads.php?ubb=dosearch&topic=1&fromsearch=1 HTTP/1.1
  sockwrite -n $sockname Host: forums.mirc.com
  sockwrite -n $sockname $crlf
}
on *:sockread:mircforum: {
  if ($sockerr > 0) return
  var %mirc 1
  sockread %mirc
  if (%mirc == 0) || (%mirc.check > 4) { 
    sockclose $sockname 
    if (%mirc.linktemp != $null) && (%mirc.linktemp != on) && (%mirc.linktemp != %Topic.MIRC) {
      set %Topic.MIRC %mirc.linktemp
      $turl(mIRC,mircnews,$striphtml(%mirc.title),http://forums.mirc.com $+ $striphtml(%mirc.linktemp),%mirc.by)
      ;surl http://forums.mirc.com $+ $striphtml(%mirc.linktemp) mirc
      unset %mirc.*
    }
  }
  else {
    if (%mirc.check == 1) var %mircr = /(.*)Go to first unread post in topic(.*)/ig 
    if (%mirc.check == 2) var %mircr = /<a href="(.*)">/ig
    if (%mirc.check == 3) var %mircr = /(.*)/ig
    if (%mirc.check == 4) var %mircr = /<a href="/ubbthreads.php\?ubb=showprofile\&User=(.*)">(.*)</a> /ig
    if ($regex(mircforum, %mirc, %mircr) > 0) {
      if (%mirc.check == 2) { set %mirc.linktemp $regml(mircforum,1) }
      if (%mirc.check == 3) { set %mirc.title $regml(mircforum,1) }
      if (%mirc.check == 4) { set %mirc.by $regml(mircforum,2) }
      inc %mirc.check
    }
  }
}

; Rumbaar ====================================================================================
alias rumbaar {
  if ($status != connected) { halt }
  sockclose rumbaarforum
  sockopen rumbaarforum public.rumbaar.net 80
  if (%Topic.RUMBAAR == $null) { set %Topic.RUMBAAR on }
  set %rumbaar.check 1
}
on *:sockopen:rumbaarforum: { 
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /index.php?type=rss;action=.xml HTTP/1.1
  sockwrite -n $sockname Host: www.public.rumbaar.neT
  sockwrite -n $sockname $crlf
}
on *:sockread:rumbaarforum: {
  if ($sockerr > 0) return
  var %rumbaar
  sockread %rumbaar
  ;echo -a %rumbaar
  if (%rumbaar == 0) || (%rumbaar.check > 3) { 
    sockclose $sockname 
    if (%rumbaar.linktemp != $null) && (%rumbaar.linktemp != on) && (%rumbaar.linktemp != %Topic.RUMBAAR) {
      set %Topic.RUMBAAR %rumbaar.linktemp
      ;;$turl(site,feed,title,url,by)
      $turl(Rumbaar,rumbaarnews,%rumbaar.title,$replace(%rumbaar.linktemp,&,&),n/a)
    }
    unset %rumbaar.* 
  }
  else {
    if (%rumbaar.check == 1) var %rumbaarr = /<item>/ig
    if (%rumbaar.check == 2) var %rumbaarr = /<title><!\[CDATA\[(.*)]]><\/title>/ig 
    if (%rumbaar.check == 3) var %rumbaarr = /<link>(.*)<\/link>/ig
    if ($regex(rumbaarforum, %rumbaar, %rumbaarr) > 0) {
      if (%rumbaar.check == 2) set %rumbaar.title $regml(rumbaarforum,1)
      if (%rumbaar.check == 3) set %rumbaar.linktemp $regml(rumbaarforum,1)
      inc %rumbaar.check
    }
  }
}


; SoulFly ====================================================================================
alias soulfly { if ($status != connected) { halt } | sockclose getsf | sockopen getsf www.soulfly-irc.com 80 }
on *:sockopen:getsf:{
  if ($sockerr > 0) { echo -at $sockname $+ : $1- }
  sockwrite -n $sockname GET /sfpost.php HTTP/1.0
  sockwrite -n $sockname Host: www.soulfly-irc.com
  sockwrite -n $sockname $crlf
}
on *:sockread:getsf: {
  if ($sockerr) { sockclose $sockname | halt }
  var %sf | sockread %sf
  if (*SoulFly Latest Posts* iswm %sf) {
    tokenize 165 %sf
    if ($4 != %Topic.SF) && (ERROR--CAN'T CONNECT TO SERVER !isin $2-) && ($2 != $null) {
      $turl(SoulFly,sfnews,$striphtml($2),$striphtml($4),$3)
      set %Topic.SF $4
    }
    sockclose getsf
  }
}

; TG007 =======================================================================================
alias newsck { if ($status != connected) { halt } | sockclose tgnews | sockopen tgnews www.tg007.net 80 }
on *:sockopen:tgnews:{
  if ($sockerr) { sockclose $sockname | halt }
  sockwrite -n $sockname GET /scriptsocket/tgposts.php HTTP/1.0
  sockwrite -n $sockname Host: www.tg007.net $+ $crlf $+ $crlf
}
on *:sockread:tgnews: {
  if ($sockerr) { echo -a Error. | halt }
  var %newsl | sockread %newsl
  if (*TG Latest Posts* iswm %newsl) {
    tokenize 165 %newsl
    if ($3 != %Topic.TGNEWS) && (ERROR--CAN'T CONNECT TO SERVER !isin $2-) && ($2 != $null) { 
      if ($regex($3,/showtopic=(.*?)&(.*?)/)) { set %tgnewsid $regml(1) }
      var %c 1
      while ($chan(%c)) { 
        if (%FEED.tgnews. [ $+ [ $chan(%c) ] ] == on) && (($me isop $chan(%c)) || ($me ishop $chan(%c))) { 
          msg $chan(%c) Tg007 Topic Update: $striphtml($2) $striphtml($4) - http://www.tg007.net/post/ $+ %tgnewsid  
        }
        inc %c
      }
      set %Topic.TGNEWS $3
      unset %tgnewsid
    }
    sockclose tgnews
  }
}
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Your first post and you already broke the rules. mIRC script ported over to tcl + eggdrop extensions? Yeah, this isn't as straight forward as you would think. mIRC is non-standard, uses weird $+ and [ ] to adjust focus and supress spacing. It's just not like you would think... this post may simply wind up junked. who knows?!


But...


There is hope. But this will at the moment work for JUST one of your sites...

Code: Select all

# Puh Rum Pum Pum Pum

# This script will announce news just like an rss script
# as well as allowing users to type commands and see
# the latest news via notice as well. Fully configurable.
# Enjoy, and may the force be with you.... always....

# speechles was here :P

package require http
setudef flag nopubnews

namespace eval news {
   # config - make your changes here
   # trigger character
   set ary(pref) "!"

   # command used to reply to user
   # this can be a list of space delimited commands
   set ary(commands) "news"

   # amount user can issue before throttle
   set ary(throttle) 2

   # throttle time
   set ary(throttle_time) 30

   # time to announce new news items
   # this can be a list of space delimited time binds.
   # the one you wish to use for bind_time uncommented.
   # set ary(bind_time) "00* 15* 30* 45*" ; # every 15 minutes
   # set ary(bind_time) "00* 30*" ; # every 30 minutes
   set ary(bind_time) "*" ; # every 60 minutes at exactly the start of the hour

   # url to news page
   set ary(page) http://www.casafree.com/modules/news/

   # parsing regex used to gather news
   set ary(regex) {<entry .*?="(.*?)">.*?<title .*?>(.*?)</title>.*?<summary .*?>(.*?)<p}

   # max amount of news items to announce
   set ary(max_bot) 5

   # max amount of news items for users
   set ary(max_user) 5

   # display format for news messages, variables are: %description, %title, %url 
   # these can be used and will be replaced with actual values, newline (\n) will
   # let you span multiple lines if you wish. If something is too long it will
   # be cut off, be aware of this... use colors, bold, but remember to \escape any
   # special tcl characters. 
   set ary(display_format) "\[\002%title\002\] %url\n%description"

   # script version
   set ary(version) "2.2"
}

# binds
foreach bind [split $::news::ary(commands)] {
   bind pub -|- "$::news::ary(pref)$bind" ::news::pub_
   bind msg -|- "$::news::ary(pref)$bind" ::news::msg_
}
foreach bind [split $::news::ary(bind_time)] {
   bind time - $bind ::news::magic_
}
bind time - ?0* ::news::throttleclean_

namespace eval news {
   # main - time bind - magic
   proc magic_ {args} {
      news_ $::botnick [getchanhost $::botnick] $::botnick "all" "magic"
   }

   # main - msg bind - notice
   proc msg_ {nick uhost hand arg} {
         news_ $nick $uhost $hand $nick "notice"
   }

   # main - pub bind - privmsg
   proc pub_ {nick uhost hand chan arg} {
      if {[channel get $chan nopubnews]} { return }
      news_ $nick $uhost $hand $chan "privmsg"
   }

   # sub - give news
   proc news_ {nick uhost hand chan arg} {
      if {![isbotnick $nick] && [throttle_ $uhost,$chan,news $::news::ary(throttle_time)]} {
         putserv "$arg $chan :$nick, you have been Throttled! Your going too fast and making my head spin!"
      }
      set a "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"
      set t [::http::config -useragent $a]
      catch { set t [::http::geturl $::news::ary(page) -timeout 30000] } error
      # error condition 1, socket error or other general error
      if {![string match -nocase "::http::*" $error] && ![isbotnick $nick]} {
         putserv "$arg $chan :[string totitle [string map {"\n" " | "} $error]] \( $::news::ary(page) \)"
         return
      }
      # error condition 2, http error
      if {![string equal -nocase [::http::status $t] "ok"] && ![isbotnick $nick]} {
         putserv "$arg $chan :[string totitle [::http::status $t]] \( $::news::ary(page) \)"
         return
      }
      set html [::http::data $t]
      ::http::cleanup $t
      set casafreenews [regexp -all -inline "$::news::ary(regex)" $html]
      set c 0
      foreach {junk id url title description} $casafreenews {
         incr c
         if {[isbotnick $nick]} {
            if {$c > $::news::ary(max_bot)} { break }
            if {[info exists ::news::ary(last)]} { if {$id <= $::news::ary(last)} { break } }
         } elseif {$c > $::news::ary(max_user)} { break }
         regsub -all -- {<.*?>} $description - description
         set output [string map [list "%title" "[mapit_ $title]" "%description" "[mapit_ $description]]" "%url" "$url"] $::news::ary(display_format)]
         if {![string equal "magic" $arg]} {
            foreach line [split $output "\n"] { puthelp "$arg $chan :$line" }
         } else {
            foreach ch [channels] {
               if {[channel get $ch nopubnews]} { continue }
               foreach line [split $output "\n"] { puthelp "privmsg $ch :$line" }
            }
         }   
      }
      if {[string equal "magic" $arg]} { set ::news::ary(last) [lindex $casafreenews 1] }
   }

   # sub - map it
   proc mapit_ {t} { return [string map [list "'" "'" """ "\""] $t] }

   # Throttle Proc (slightly altered, super action missles) - Thanks to user
   # see this post: http://forum.egghelp.org/viewtopic.php?t=9009&start=3
   proc throttle_ {id seconds} {
      if {[info exists ::news::throttle($id)]&&[lindex $::news::throttle($id) 0]>[clock seconds]} {
         set ::news::throttle($id) [list [lindex $::news::throttle($id) 0] [set value [expr {[lindex $::news::throttle($id) 1] +1}]]]
         if {$value > $::news::ary(throttle)} { set id 1 } { set id 0 }
      } {
         set ::news::throttle($id) [list [expr {[clock seconds]+$seconds}] 1]
         set id 0
      }
   }
   # sub - clean throttled users
   proc throttleclean_ {args} {
      set now [clock seconds]
      foreach {id time} [array get ::news::throttle] {
         if {[lindex $time 0]<=$now} {unset ::news::throttle($id)}
      }
   }
}

putlog "news and announce.tcl v$::news::ary(version) loaded."
This is a script from an earlier post, included in full as all this would need to fulfill you goal would be the ability to handle _multiple_ feeds instead of just it's one. That addition would be quite trivial. As you mIRC script is regex parsing based, so is "puh rum" so hopefully you understand what to change and perhaps someone will give you an idea how to go about adding multiple sites to it ..... ;) (to be continued...)
User avatar
Trixar_za
Op
Posts: 143
Joined: Wed Nov 18, 2009 1:44 pm
Location: South Africa
Contact:

Post by Trixar_za »

*steals for another site*
Post Reply