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.

Market script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
P
Pizza_Guy
Voice
Posts: 12
Joined: Sun Jun 08, 2008 1:52 am

Market script

Post by Pizza_Guy »

I am looking for a script where people can list things to sell and then others can look them up
basic commands are
!sell
!remove
!search

there are only 3 things to sell and they are
Naq
UU
AT

most people use the layout 1k AT 160B Naq

I tried doign this myself but i ran into the issue of when writing to a file it removing all of the information already there
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

when writing to the file, instead of using the 'w' flag use the 'a' flag which will append to the end of the file.

example:

Code: Select all

set file [open file.txt a]
r0t3n @ #r0t3n @ Quakenet
P
Pizza_Guy
Voice
Posts: 12
Joined: Sun Jun 08, 2008 1:52 am

Post by Pizza_Guy »

how can i get it to remove the line for a person?
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

it depends on how you structured your file. If its structure in the format: 'nickline info_here' you can search for the nickname.

Example:

Code: Select all

set file [open file.txt r]
set read [read -nonewline $file]
close $file
set file [open file.txt w]
foreach line [split $read \n] {
    if {$line == ""} { continue }
    if {[string equal -nocase $nick [lindex [split $line] 0]]} {
        continue
    } else {
        puts $file "$line"
    }
}
close $file
r0t3n @ #r0t3n @ Quakenet
P
Pizza_Guy
Voice
Posts: 12
Joined: Sun Jun 08, 2008 1:52 am

Post by Pizza_Guy »

thank you for the help
after looking at what you wrote it appears that this is a bit beyond my current understanding
I am going to need to keep reading and learning more before i can get this working


a side note
is there a script that can do some type of fetching of links on a specific page?
so if i would do !sitemarket
it would go out and look at a determined # of the top links and past back the topic of the thread and the link

or is this again something i am going to need to learn more about?
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Its possible via the http package and a regexp to grab the links from the html code.

If you provide us the link to the page, we might be able to help you.
r0t3n @ #r0t3n @ Quakenet
P
Pizza_Guy
Voice
Posts: 12
Joined: Sun Jun 08, 2008 1:52 am

Post by Pizza_Guy »

well there are a two basically what i am looking at is this

someone says

!MarketUU it would give the say top 5 threads from here
http://herebegames.com/StarGateWarsNew/ ... m.php?f=90

i was thinking of the format
thread title | Thread link

!MarketAT - would give the top 5 from
http://herebegames.com/StarGateWarsNew/ ... m.php?f=91

i was thinking of the format
thread title | Thread link
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# amount of posts to show
variable herebe_limit 5

package require http

setudef flag herebegames

bind pub - !MarketUU herebe:games1
bind pub - !MarketAT herebe:games2
bind pub - !MarketPlanet herebe:games3
bind pub - !MarketDiscussion herebe:games4
bind pub - !Awards herebe:games5

proc herebe:games1  {nick uhost handle chan text} {
  herebe:games $nick $uhost $handle $chan 90 $text
}

proc herebe:games2  {nick uhost handle chan text} {
  herebe:games $nick $uhost $handle $chan 91 $text
}

proc herebe:games3  {nick uhost handle chan text} {
  herebe:games $nick $uhost $handle $chan 93 $text
}

proc herebe:games4  {nick uhost handle chan text} {
  herebe:games $nick $uhost $handle $chan 94 $text
}

proc herebe:games5  {nick uhost handle chan text} {
  herebe:games $nick $uhost $handle $chan 89 $text
}

proc herebe:games {nick uhost handle chan tag text} {
   if {[lsearch -exact [channel info $chan] +herebegames] == -1} { return }
   set query "http://herebegames.com/StarGateWarsNew/viewforum.php?f=$tag"
   set ua "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"
   set http [::http::config -useragent $ua -useragent "utf-8"]
   catch {set http [::http::geturl "$query" -timeout [expr 1000 * 5]]} error
   if {[string match -nocase "*couldn't open socket*" $error]} {
      putserv "privmsg $chan :Socket Error accessing '$query' .. It must be down.. :("
      return 0
   }
   if { [::http::status $http] == "timeout" } {
      putserv "privmsg $chan :Connection has timed out"
      return 0
   }
   set html [::http::data $http]
   ::http::cleanup $http

   regsub {(^.+?)<td class="row3" colspan="6"><b class="gensmall">Topics</b></td>} $html "" html
   set counter 0
   while {$counter < $::herebe_limit} {
      regexp -nocase {<a title.+?href=.+?class=.+?">(.+?)</a>.+?<p class="topicdetails">.*?</a>.*?<a href="\.(.+?)">} $html -> subject url
      set url "http://herebegames.com/StarGateWarsNew[string map {& &} $url]"
      regsub -nocase {<a title.+?href=.+?class=.+?">.+?</a>.+?<p class="topicdetails">.*?</a>.*?<a href=".+?">} $html "" html
      incr counter 1
      putserv "privmsg $chan :\002$subject\002 - $url"
   }
   return 1
}

putlog "herebegames loaded."
Use the partyline and .chanset #youchan +herebegames to activate on each desired channel. Below is an example of how this looks for marketuu. Also added examples of how you can add all the forum sections to triggers and have one single procedure scrape them all. Keep in mind the scraping template is designed for just this site, it won't work for others, but will for every forum section of that site.
<speechles> !marketUU
<sp33chy> selling 38 mil UU @ 720 bil per mil - http://herebegames.com/StarGateWarsNew/ ... 7#p1398657
<sp33chy> Buying 1mil UU (700 bil / 1mil uu) ~ online - http://herebegames.com/StarGateWarsNew/ ... 8#p1398628
<sp33chy> buying 4,5mil uu / 720bil per 1 mil - http://herebegames.com/StarGateWarsNew/ ... 8#p1398308
<sp33chy> Selling 1mil UU for 5k Turns - http://herebegames.com/StarGateWarsNew/ ... 6#p1398266
<sp33chy> Selling 15m UU 750b/m - http://herebegames.com/StarGateWarsNew/ ... 1#p1393781
P
Pizza_Guy
Voice
Posts: 12
Joined: Sun Jun 08, 2008 1:52 am

Post by Pizza_Guy »

Thank you. It works like a charm

i think i made a little head room with the other script but i can't post it i not at home, stupid work
Post Reply