!! As of Sunday 8th of April 2012 This script has stopped working !!
!! As of Sunday 8th of April 2012 This script has stopped working !!
Howdy all..
For all of you (perhaps not many) who are interested in science, and/or are running a science related chan. I complied a set of RSS feeds from physorg.com.
The original Code was skilfully fashioned using a cocktail of black and white magic during a full moon on the highest peak of the northern plains by Lord Napa the socket wizard of the north.
All I did was copy the original code, and paste it down to add another feed link.. tweaked colours and category heading... and sure I know this whole thing could have been squeezed into one body of code, but .. well you know me.. im not much of a coder, but its a worker. I also added a feed menu list that will be noticed.
Of course feel free to mess about with .. tho perhaps it might be nice to quote napa if your re-posting a modded version.
Anyway the commands are simple enough
!news - will notice the list of feeds.. the rest is self explanatory
will display 3 feeds, you can edit that yourself.. also you can add in any other rss. 2.0 from that site using the same code.. (there seems to be quite a good selection of feeds: http://www.physorg.com/feeds/ )
Enjoy science fans
!! As of Sunday 8th of April 2012 This script has stopped working !!
!! As of Sunday 8th of April 2012 This script has stopped working !!
on *:text:!News:#:{
notice $nick Hi there $nick Here is the list of available news headline feeds: (!phynews = General Physics) - (!qmnews = Quantum Physics) - (!nanonews = Nanotechnology) - (!spacenews = General Space) - (!astronews = Astronomy) - (!chemnews = Chemistry) - (!bionews = Biology) - (!mathnews = Mathematics) - (!technews - Technology)
}
on $*:text:/^!phnews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics)) sockclose physics
sockopen physics www.physorg.com 80
sockmark physics msg # 0,14 Physics News:
}
}
on *:sockopen:physics: {
sockwrite -nt physics GET /rss-feed/physics-news/ HTTP/1.1
sockwrite -nt physics Host: $+($sock(physics).addr,$str($crlf,2))
}
on *:sockread:physics: {
var %physics | sockread %physics
if (%phy = 5) { sockclose physics }
if ($regex(%physics,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!qmnews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics2)) sockclose physics2
sockopen physics2 www.physorg.com 80
sockmark physics2 msg # 0,14 Quantum Physics News:
}
}
on *:sockopen:physics2: {
sockwrite -nt physics2 GET /rss-feed/physics-news/quantum-physics/ HTTP/1.1
sockwrite -nt physics2 Host: $+($sock(physics2).addr,$str($crlf,2))
}
on *:sockread:physics2: {
var %physics2 | sockread %physics2
if (%phy = 5) { sockclose physics2 }
if ($regex(%physics2,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics2,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics2).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!spacenews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics3)) sockclose physics3
sockopen physics3 www.physorg.com 80
sockmark physics3 msg # 0,14 Space News:
}
}
on *:sockopen:physics3: {
sockwrite -nt physics3 GET /rss-feed/space-news/space-exploration/ HTTP/1.1
sockwrite -nt physics3 Host: $+($sock(physics3).addr,$str($crlf,2))
}
on *:sockread:physics3: {
var %physics3 | sockread %physics3
if (%phy = 5) { sockclose physics3 }
if ($regex(%physics3,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics3,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics3).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!technews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics4)) sockclose physics4
sockopen physics4 www.physorg.com 80
sockmark physics4 msg # 0,14 Technology News:
}
}
on *:sockopen:physics4: {
sockwrite -nt physics4 GET /rss-feed/technology-news/ HTTP/1.1
sockwrite -nt physics4 Host: $+($sock(physics4).addr,$str($crlf,2))
}
on *:sockread:physics4: {
var %physics4 | sockread %physics4
if (%phy = 5) { sockclose physics4 }
if ($regex(%physics4,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics4,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics4).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!chemnews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics5)) sockclose physics5
sockopen physics5 www.physorg.com 80
sockmark physics5 msg # 0,14 Chemistry News:
}
}
on *:sockopen:physics5: {
sockwrite -nt physics5 GET /rss-feed/chemistry-news/ HTTP/1.1
sockwrite -nt physics5 Host: $+($sock(physics5).addr,$str($crlf,2))
}
on *:sockread:physics5: {
var %physics5 | sockread %physics5
if (%phy = 5) { sockclose physics5 }
if ($regex(%physics5,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics5,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics5).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!bionews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics6)) sockclose physics6
sockopen physics6 www.physorg.com 80
sockmark physics6 msg # 0,14 Biology News:
}
}
on *:sockopen:physics6: {
sockwrite -nt physics6 GET /rss-feed/biology-news/ HTTP/1.1
sockwrite -nt physics6 Host: $+($sock(physics6).addr,$str($crlf,2))
}
on *:sockread:physics6: {
var %physics6 | sockread %physics6
if (%phy = 5) { sockclose physics6 }
if ($regex(%physics6,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics6,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics6).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!mathnews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics7)) sockclose physics7
sockopen physics7 www.physorg.com 80
sockmark physics7 msg # 0,14 Mathematics News:
}
}
on *:sockopen:physics7: {
sockwrite -nt physics7 GET /rss-feed/science-news/mathematics/ HTTP/1.1
sockwrite -nt physics7 Host: $+($sock(physics7).addr,$str($crlf,2))
}
on *:sockread:physics7: {
var %physics7 | sockread %physics7
if (%phy = 5) { sockclose physics7 }
if ($regex(%physics7,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics7,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics7).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!astronews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics8)) sockclose physics8
sockopen physics8 www.physorg.com 80
sockmark physics8 msg # 0,14 Astronomy News:
}
}
on *:sockopen:physics8: {
sockwrite -nt physics8 GET /rss-feed/space-news/astronomy/ HTTP/1.1
sockwrite -nt physics8 Host: $+($sock(physics8).addr,$str($crlf,2))
}
on *:sockread:physics8: {
var %physics8 | sockread %physics8
if (%phy = 5) { sockclose physics8 }
if ($regex(%physics8,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics8,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics8).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
on $*:text:/^!nanonews$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics9)) sockclose physics9
sockopen physics9 www.physorg.com 80
sockmark physics9 msg # 0,14 NanoTechology News
}
}
on *:sockopen:physics9: {
sockwrite -nt physics9 GET /rss-feed/nanotech-news/ HTTP/1.1
sockwrite -nt physics9 Host: $+($sock(physics9).addr,$str($crlf,2))
}
on *:sockread:physics9: {
var %physics9 | sockread %physics9
if (%phy = 5) { sockclose physics9 }
if ($regex(%physics9,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics9,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $sock(physics9).mark $hget(phy,1) 14 @ $regml(1)
}
}
}
Cheers Napa
oh i think it would be alot of work for you and time to remix your script.. I really think its the links or something that needs to be changed on the originally posted one.
i recently upgraded to firefox10 ... and when putting in links to an example of one of the rss feed pages it strips the www. ... and as a test i also tried the same in ie8.. ie also strips the www out, but leaves the http in.. this is odd since i defiantly remember ie not doing that before.. i thought FF10 was doing it since the upgrade. So.. this is a wild guess, perhaps i must strip all the www. out of the script.. Ill give it a try.
Also what dose the "80" after each root link mean?
Also perhaps the problem is with these parts "HTTP/1.1"
perhaps phyorg have upgraded from 1.1? As i said earlier I have emailed physorg to ask about that very thing.. but ive been waiting for almost a week. no reply.. Ill try mail them again and see if they can shed some light on what went wrong... i just dont really expect a reply tho since its not exactly in relation to physics :/
Ive run debug mode on it.. nothing shows up to indicate what the problem might be
There is nothing displayed in status window to indicate what the problem is.
Ive had a few others look/try it too with no success. and they dont see why its not working.
Ive spent the best part of a week on and off, on my own trying and trying to get this working again.. no idea whatsoever.. like as i said if i AT LEAST knew what the problem is i could then "attempt" to fix it myself.. but everything is much much more harder since i dont even know the "why" yet.. never mind the "how" to fix part.
I did not change the code in anyway before it stopped working, in fact wasnt even working on the bot at all that weekend... I checked my pc for the usually things.. malware, viruses.. etc and to the best of my ability it seems clean enough. So i doubt the code was hacked or modified in anyway. Yet all the said the links seem exactly the same.. the html layout looks the same on the site. I wish i had taken a screenshot of rss pages and a screenshot of all the source page codes of each rss link so i would at least have something to compare with it. I might have then been able to see where the problem or change is.
Anyway, ill keep emailing mailing physorg, right now they seem to be my only hope of getting this working again.
regards
ah nice.. tho that is specific to the hawkee forum?... did u post that in here by accident?
nice one tho
regarding the news script itself.. i tried lots of things, cant get it working anymore.. also tried a bunch of irc scripting chans.. nobody seems to want to help. Its a pitty i only got a few weeks out of this.. .. even tho we only had it working for a short time its sorely missed. I cant find any other rss or socket solution.
I even tried mailing physorg to ask if they changed the html in some way... didnt get a reply.
I dont suppose anyone on hawkee can fix this? or even tell me why is stopped working?
regards
They work great on any chat server, depending how the code is done, for instance a good friend of mine uses tinyurl to get the feeds. here's an example
on *:Join:*: {
if ($nick == $me) {
.timer.hawkee 0 15 hawkee
}
}
; Menu =====================================================================================
menu channel {
Feeder
.$iif(%Feed.hknews. [ $+ [ $active ] ] == on,$style(1)) Hawkee: $iif(%Feed.hknews. [ $+ [ $active ] ] == on,unset %Feed.hknews. [ $+ [ $active ] ],set %Feed.hknews. [ $+ [ $active ] ] on)
.-
.Add All $chan : {
set %Feed.hknews. [ $+ [ $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
}
}
}
; 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
}
}
}
The creator of this is err0r from TG007.net
I should probably point out this is not working anymore whatsoever.
Didnt edit it in anyway.. i just woke up and its not working. Got others to try load it .. same thing. I myself reloaded it, rebooted..the bot..etc etc still a no go.
Have the sockets expired on this already? Its a shame i got about a month out of it.
Dam you RSS feeds.. dam you to hell and back.
Yet another perfectly working rss feed, suddenly decides to stop working, and yet again im now left with no rss solution.
Its beyond a joke now,, it really is
Im starting to think rss and irc was never going to work, at least not properly.. and certainly not for any substantial length of time.
Not saying its any fault of napa's ... I assume the sockets are old now.. but its just the same old story time and time again with anything to do with rss or sockets.
/me is not a happy camper this morning.
I suppose i should make a note of that in the snippet text up top here too.
liked and rated 8.
it's a 10 for usefulness
it's a 9 for coding (difficult to follow but exceptional as usual from NAPA)
and a 7 for editability.
If you could set the colours and the style to your own preferences then it would be 10 overall.
I've wanted something like this for ages now, but sockets never locked for me.
I was talking about Napa's code being hard to edit, not yours. While his is smaller, that doesn't mean it's better or more efficient. Everyone has their own take on coding, your snippet can work just the same and for editing I would prefer it over Napa's honestly. Not to say his is bad, but I think most would find it difficult to change ;)
Thanks Nappa.. another fantastic cleanup.. god you make it look so easy.
Aucun50.. yes I know how painful it must be to look at my code, and yes I made lots of mistakes in it, which took me even more time to look through it to see where the mistake was. Napas version is so much better and more efficient , however the problem with napas is I wouldn't have a clue how to modify his at all. For example if I wanted to add or take out a feed on my code i would just delete or copy/paste another one down and edit a few things, but with napas the whole thing is integrated into one body of code. In addition if I only wanted one feed to return 2 results but another one to return 3.. or if I wanted the "start of return line category heading" to be in a different colour to the others.. i could quite easily modify my own code to do that.. but napas, despite it being a far superior piece of code, ide be totally stuck how to even start to workout how to make changes like that.
I need something flexible in the sense that its simple enough for me to edit in the future. Unfortunately because of my non existent coding skills, when it comes to running scripts on my bot I usually choose the most simplest & crudest scripts no matter how messy and un-efficient they are so at least I can edit it. In short what i mean is, i choose flexibility over efficiency.. (but i must stress I only think like that simply because i cant read or code anything complicated like napa did.)
For me to be up at the level of napa on others on this forum would require me to go back to university to do a degree in programming, which much as ide love to do, im at the age and stage of my life that I dont have time or ability (in terms of taking on such a heavy weight and academic discipline ). I know folks that have gone to college to study programming and they drop out after a few years because its too tough.. and they are far more academicly minded then me, so what hope have I got.
folks thanks for the suggestions, napa thanks once again for making the code far more smaller and efficient, and of course for the initial help with the original code.
regards
pan
EDIT: perhaps this computer hardware analergy might click with you. My code would be like an oldish slow desktop pc, one i can up grade or modify with relative ease. Napa code is like a super modern laptop.. works better, smaller, quieter, faster.. but much harder (at least for me) to modify or upgrade.
:D
Odd way to go about it adding so many sockets that is.. You should have just used one socket to check for the news you are looking for on that one site. It wouldn't be hard to do...
What I mean is you can find away to make it do it in one socket instead of making 9 sockets.. Here is just one way keep in mind I haven't coded in msl in some time...
on $*:text:/^!(ph|qm|nano|space|astro|chem|bio|math|tech)news$/iS:#:{
if (!%f) { inc -u5 %f
if ($sock(physics)) sockclose physics
sockopen physics www.physorg.com 80
sockmark physics $+(/rss-feed/,$iif($regml(1) = ph,physics-news,$iif($regml(1) = qm,$&
physics-news/quantum-physics,$iif($regml(1) = nano,nanotech-news,$iif($regml(1) = space,$&
space-news/space-exploration,$iif($regml(1) = astro,space-news/astronomy,$iif($regml(1) = chem,$&
chemistry-news,$iif($regml(1) = bio,biology-news,$iif($regml(1) = math,science-news/mathematics,$iif($regml(1) = tech,$&
technology-news))))))))),/) msg # 0,14 $iif($regml(1) = ph,Physics,$iif($regml(1) = qm,Quantum Physics,$iif($regml(1) = nano,$&
NanoTechology,$iif($regml(1) = space,Space,$iif($regml(1) = astro,Astronomy,$iif($regml(1) = chem,$&
Chemistry,$iif($regml(1) = bio,Biology,$iif($regml(1) = math,Mathematics,$iif($regml(1) = tech,Technology))))))))) News:
}
}
on *:sockopen:physics: {
sockwrite -nt physics GET $gettok($sock(physics).mark,1,32) HTTP/1.1
sockwrite -nt physics Host: $+($sock(physics).addr,$str($crlf,2))
}
on *:sockread:physics: {
var %physics | sockread %physics
if (%phy = 5) { sockclose physics }
if ($regex(%physics,/<title>(.+)<\/title>/)) { inc -u5 %phy
if (%phy isnum 2-4) { hadd -m phy 1 $regml(1) }
}
if ($regex(%physics,/<link>(.+w{3}\.physorg\.com\/\S+)<\/link>/)) { inc -u5 %phyy
if (%phyy isnum 2-4) { $gettok($sock(physics).mark,2-,32) $hget(phy,1) 14 @ $regml(1)
}
}
}