egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Market script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Pizza_Guy
Voice


Joined: 08 Jun 2008
Posts: 12

PostPosted: Fri Jun 13, 2008 9:20 pm    Post subject: Market script Reply with quote

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
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri Jun 13, 2008 9:38 pm    Post subject: Reply with quote

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:
set file [open file.txt a]

_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
Pizza_Guy
Voice


Joined: 08 Jun 2008
Posts: 12

PostPosted: Fri Jun 13, 2008 11:09 pm    Post subject: Reply with quote

how can i get it to remove the line for a person?
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Jun 14, 2008 7:50 am    Post subject: Reply with quote

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:
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
Back to top
View user's profile Send private message MSN Messenger
Pizza_Guy
Voice


Joined: 08 Jun 2008
Posts: 12

PostPosted: Sat Jun 14, 2008 9:55 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sun Jun 15, 2008 8:49 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Pizza_Guy
Voice


Joined: 08 Jun 2008
Posts: 12

PostPosted: Mon Jun 16, 2008 7:44 pm    Post subject: Reply with quote

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/viewforum.php?f=90

i was thinking of the format
thread title | Thread link

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

i was thinking of the format
thread title | Thread link
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Jun 17, 2008 12:03 am    Post subject: Reply with quote

Code:
# 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 {&amp; &} $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.
Quote:
<speechles> !marketUU
<sp33chy> selling 38 mil UU @ 720 bil per mil - http://herebegames.com/StarGateWarsNew/viewtopic.php?f=90&t=116872&sid=4a210084b71293d5cbeed13dc1a29506&p=1398657#p1398657
<sp33chy> Buying 1mil UU (700 bil / 1mil uu) ~ online - http://herebegames.com/StarGateWarsNew/viewtopic.php?f=90&t=116690&sid=4a210084b71293d5cbeed13dc1a29506&p=1398628#p1398628
<sp33chy> buying 4,5mil uu / 720bil per 1 mil - http://herebegames.com/StarGateWarsNew/viewtopic.php?f=90&t=116860&sid=4a210084b71293d5cbeed13dc1a29506&p=1398308#p1398308
<sp33chy> Selling 1mil UU for 5k Turns - http://herebegames.com/StarGateWarsNew/viewtopic.php?f=90&t=116878&sid=4a210084b71293d5cbeed13dc1a29506&p=1398266#p1398266
<sp33chy> Selling 15m UU 750b/m - http://herebegames.com/StarGateWarsNew/viewtopic.php?f=90&t=114870&sid=4a210084b71293d5cbeed13dc1a29506&p=1393781#p1393781

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Pizza_Guy
Voice


Joined: 08 Jun 2008
Posts: 12

PostPosted: Tue Jun 17, 2008 2:05 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber