Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias autostatus {
- if ($network != Mibbit) { halt }
- elseif (%inuse == yes) { timer 1 30 autostatus }
- else { set %inuse yes | set %info auto | sockopen tpporg www.twitchplayspokemon.org 80 | timertpp 1 10 timeout }
- timerauto 1 600 autostatus
- }
- alias timeout {
- set %inuse no
- if (%info != auto) { msg %tppchan The request timed out due to Raif's shit internet. Sorry. }
- unset %info
- unset %count*
- unset %tnick
- unset %tpp.*
- }
- on $*:TEXT:/^!tppstatus/iS:%tppchan:{
- if ($network != Mibbit) { halt }
- elseif (%inuse == yes) { msg %tppchan $nick $+ : Someone else has requested the same information! Please be patient. }
- else { set %inuse yes | set %info status | sockopen tpporg www.twitchplayspokemon.org 80 | timertpp 1 10 timeout }
- }
- on $*:TEXT:/^!tppteam/iS:%tppchan:{
- if ($network != Mibbit) { halt }
- elseif (%inuse == yes) { msg %tppchan $nick $+ : Someone else has requested the same information! Please be patient. }
- else { set %inuse yes | set %tnick $nick | set %info team | sockopen tpporg www.twitchplayspokemon.org 80 | timertpp 1 10 timeout }
- }
- on *:SOCKOPEN:tpporg:{
- sockwrite -n tpporg GET / HTTP/1.1
- sockwrite -n tpporg Host: twitchplayspokemon.org
- sockwrite -n tpporg Connection: keep-alive
- sockwrite -n tpporg Cache-Control: max-age=0
- sockwrite -n tpporg Accept: text/html
- sockwrite -n tpporg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
- sockwrite -n tpporg Accept-Encoding: text
- sockwrite -n tpporg Accept-Language: en-US,en;q=0.8
- sockwrite -n tpporg Cookie: more_info_badges=1; more_info=1; more_info_e4=1
- sockwrite -n $sockname $crlf $+ $crlf
- }
- on *:SOCKREAD:tpporg:{
- if ($sockerr > 0) return
- :nextread
- sockread %tpp
- if ($sockbr == 0) { return }
- if (%tpp) {
- inc %count.lines
- if ($network != Mibbit) { sockclose tpporg | halt }
- elseif ($regex(%tpp,/Last\supdate\72/) > 0) { var %x $regsubex(%tpp,/<[^<>]+>/gS,$null) | set %tpp.lastupdate $regsubex(%x,/^\s+/g,$null) }
- elseif (%info == status) || (%info == auto) {
- if ($regex(%tpp,/<p>.*\72 <strong>.*<\/strong><\/p>/) > 0) {
- inc %count
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- var %x $regsubex(%x,/^\s+/g,$null)
- set %tpp.status. [ $+ [ %count ] ] $regsubex(%x,/é/g,é)
- }
- elseif (%info == auto) && ($regex(%tpp,/<span class\="milestone-name">.*<\/span/) > 0) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.lastmilestone $regsubex(%x,/^\s+/g,$null)
- }
- elseif (%info == auto) && ($regex(%tpp,/<td class\="text-right"><small>/) > 0) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.lastmilestonedate $regsubex(%x,/^\s+/g,$null)
- }
- }
- elseif (%info == team) {
- if ($regex(%tpp,/<th>.*<img src\="/) > 0) && (%count.lines < 300) {
- inc %count.name
- if (%count.name < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- var %x $regsubex(%x,/^\s+/g,$null)
- set %tpp.name. [ $+ [ %count.name ] ] $regsubex(%x,/\(&#.*;\)/g,$null)
- if ($regex(%tpp,♂) > 0) { set %tpp.gender. [ $+ [ %count.name ] ] Male }
- elseif ($regex(%tpp,♀) > 0) { set %tpp.gender. [ $+ [ %count.name ] ] Female }
- else { set %tpp.gender. [ $+ [ %count.name ] ] Genderless }
- }
- }
- elseif ($regex(%tpp,/<small class\="pokemon-name"><em>/) > 0) && (%count.lines < 300) {
- inc %count.pokname
- if (%count.pokname < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.pokname. [ $+ [ %count.pokname ] ] $regsubex(%x,/^\s+/g,$null)
- }
- }
- elseif ($regex(%tpp,/<td class\="pokemon-valign-middle">Level/) > 0) && (%count.lines < 300) {
- inc %count.level
- if (%count.level < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.level. [ $+ [ %count.level ] ] $regsubex(%x,/^\s+/g,$null)
- }
- }
- elseif ($regex(%tpp,/<td class\="pokemon-valign-middle">.*<\/em><\/td>/) > 0) && (%count.lines < 300) {
- inc %count.nickname
- if (%count.nickname < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.nickname. [ $+ [ %count.nickname ] ] $regsubex(%x,/^\s+/g,$null)
- }
- }
- elseif ($regex(%tpp,/<td>.*(hold|held).*<\/td>/i) > 0) && (%count.lines < 300) {
- inc %count.held
- if (%count.held < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.held. [ $+ [ %count.held ] ] $regsubex(%x,/^\s+/g,$null)
- }
- }
- elseif ($regex(%tpp,/<td class="pokemon-valign-middle">/) > 0) && (%count.lines < 300) { set %count.temp %count.lines }
- elseif ($regex(%tpp,/<ul class\="pokemon-moves">/) > 0) && ($calc($(%count.lines)-$(%count.temp)) == 1) && (%count.lines < 300) {
- inc %count.movpoke
- if (%count.movpoke < 7) { set %move on }
- }
- elseif ($regex(%tpp,/<li/) > 0) && (%move == on) && (%count.lines < 300) {
- inc %count.move
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- var %y tpp.move. $+ %count.movpoke $+ %count.move
- set % [ $+ [ %y ] ] $regsubex(%x,/^\s+/g,$null)
- }
- elseif ($regex(%tpp,/</ul>/) > 0) && (%move == on) && (%count.lines < 300) { set %move off | set %count.move 0 }
- elseif ($regex(%tpp,/<li><em>Ability\72<\/em>/) > 0) && (%count.lines < 300) { set %count.temp %count.lines }
- elseif ($regex(%tpp,/<li><attr/) > 0) && ($calc($(%count.lines)-$(%count.temp)) == 1) && (%count.lines < 300) {
- inc %count.ability
- if (%count.ability < 7) {
- var %x $regsubex(%tpp,/<[^<>]+>/g,$null)
- set %tpp.ability. [ $+ [ %count.ability ] ] $regsubex(%x,/^\s+/g,$null)
- }
- }
- }
- }
- goto nextread
- }
- on *:SOCKCLOSE:tpporg:{
- echo -s $timestamp tpp socket closed
- timertpp off
- set %inuse no
- if (%info = auto) {
- set %tpp.autostatus 04 $+ TPP Auto Update: %tpp.status.1 $(|) %tpp.status.2 $(|) %tpp.status.3 $(|) %tpp.status.4
- if (%autostatus.old != %tpp.autostatus) { msg %tppchan %tpp.autostatus $(|) %tpp.status.5 $(|) %tpp.lastupdate }
- set %tpp.automilestone 04 $+ TPP Auto Update: %tpp.lastmilestonedate - %tpp.lastmilestone
- if (%automilestone.old != %tpp.automilestone) { msg %tppchan %tpp.automilestone }
- set %autostatus.old %tpp.autostatus
- set %automilestone.old %tpp.automilestone
- }
- elseif (%info = status) { msg %tppchan 04 $+ %tpp.status.1 $(|) %tpp.status.2 $(|) %tpp.status.3 $(|) %tpp.status.4 $(|) %tpp.status.5 $(|) %tpp.lastupdate }
- elseif (%info = team) {
- msg %tnick 04 $+ %tpp.name.1 $(|) %tpp.pokname.1 $(|) %tpp.nickname.1 $(|) %tpp.gender.1 $(|) %tpp.level.1 $(|) %tpp.held.1
- msg %tnick 07 $+ Moves: %tpp.move.11 $+ , %tpp.move.12 $+ , %tpp.move.13 $+ , %tpp.move.14 $(|) Ability: %tpp.ability.1
- if (%tpp.name.2 != $null) msg %tnick 04 $+ %tpp.name.2 $(|) %tpp.pokname.2 $(|) %tpp.nickname.2 $(|) %tpp.gender.2 $(|) %tpp.level.2 $(|) %tpp.held.2
- if (%tpp.name.2 != $null) msg %tnick 07 $+ Moves: %tpp.move.21 $+ , %tpp.move.22 $+ , %tpp.move.23 $+ , %tpp.move.24 $(|) Ability: %tpp.ability.2
- if (%tpp.name.3 != $null) msg %tnick 04 $+ %tpp.name.3 $(|) %tpp.pokname.3 $(|) %tpp.nickname.3 $(|) %tpp.gender.3 $(|) %tpp.level.3 $(|) %tpp.held.3
- if (%tpp.name.3 != $null) msg %tnick 07 $+ Moves: %tpp.move.31 $+ , %tpp.move.32 $+ , %tpp.move.33 $+ , %tpp.move.34 $(|) Ability: %tpp.ability.3
- if (%tpp.name.4 != $null) msg %tnick 04 $+ %tpp.name.4 $(|) %tpp.pokname.4 $(|) %tpp.nickname.4 $(|) %tpp.gender.4 $(|) %tpp.level.4 $(|) %tpp.held.4
- if (%tpp.name.4 != $null) msg %tnick 07 $+ Moves: %tpp.move.41 $+ , %tpp.move.42 $+ , %tpp.move.43 $+ , %tpp.move.44 $(|) Ability: %tpp.ability.4
- if (%tpp.name.5 != $null) msg %tnick 04 $+ %tpp.name.5 $(|) %tpp.pokname.5 $(|) %tpp.nickname.5 $(|) %tpp.gender.5 $(|) %tpp.level.5 $(|) %tpp.held.5
- if (%tpp.name.5 != $null) msg %tnick 07 $+ Moves: %tpp.move.51 $+ , %tpp.move.52 $+ , %tpp.move.53 $+ , %tpp.move.54 $(|) Ability: %tpp.ability.5
- if (%tpp.name.6 != $null) msg %tnick 04 $+ %tpp.name.6 $(|) %tpp.pokname.6 $(|) %tpp.nickname.6 $(|) %tpp.gender.6 $(|) %tpp.level.6 $(|) %tpp.held.6
- if (%tpp.name.6 != $null) msg %tnick 07 $+ Moves: %tpp.move.61 $+ , %tpp.move.62 $+ , %tpp.move.63 $+ , %tpp.move.64 $(|) Ability: %tpp.ability.6
- msg %tnick %tpp.lastupdate
- }
- unset %info
- unset %count*
- unset %tnick
- unset %tpp.*
- }
Advertisement
Add Comment
Please, Sign In to add comment