| View previous topic :: View next topic |
| Author |
Message |
Pizza_Guy Voice
Joined: 08 Jun 2008 Posts: 12
|
Posted: Fri Jun 13, 2008 9:20 pm Post subject: Market script |
|
|
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 |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Jun 13, 2008 9:38 pm Post subject: |
|
|
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 |
|
 |
Pizza_Guy Voice
Joined: 08 Jun 2008 Posts: 12
|
Posted: Fri Jun 13, 2008 11:09 pm Post subject: |
|
|
| how can i get it to remove the line for a person? |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Jun 14, 2008 7:50 am Post subject: |
|
|
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 |
|
 |
Pizza_Guy Voice
Joined: 08 Jun 2008 Posts: 12
|
Posted: Sat Jun 14, 2008 9:55 pm Post subject: |
|
|
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 |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sun Jun 15, 2008 8:49 am Post subject: |
|
|
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 |
|
 |
Pizza_Guy Voice
Joined: 08 Jun 2008 Posts: 12
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue Jun 17, 2008 12:03 am Post subject: |
|
|
| 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 {& &} $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' eggdrop tcl archive |
|
| Back to top |
|
 |
Pizza_Guy Voice
Joined: 08 Jun 2008 Posts: 12
|
Posted: Tue Jun 17, 2008 2:05 pm Post subject: |
|
|
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 |
|
 |
|