Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Twitter Script (Timeline & Tweets) v1.0 [[Beta Unfinished Version]]
- ;Made by nick1 on May 07 2012
- ;Last edit May 07 2012
- ;2DO everything
- ;http://api.twitter.com/1/statuses/user_timeline.json?screen_name=USER&count=3
- ;http://search.twitter.com/search.json?q=blue%20angels&rpp=MAX
- ;http://api.twitter.com/1/statuses/show/TheLongAssIDHere.json
- ;https://api.twitter.com/1/trends/23424977.json -- 23424977 is US and 1 is global
- ;raw 408:*: msg $2 $remove($strip($13-),$chr(9))
- off $*:text:/^[!@.](twitter|tweet|hashtag|trending|tt|trends)(\s|$)/Si:*: {
- tokenize 32 $strip($1-)
- $iif($chan == #rsbot,halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- if ($($+(%,botflood.,$nick),2) >= 50) {
- ignore -u60 $address($nick,2)
- msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
- halt
- }
- elseif ($($+(%,botflood.,$nick),2) >= 40) {
- msg $chan $+($nick,$chr(44)) Please do not flood the bot.
- inc -z $+(%,botflood.,$nick) 20
- halt
- }
- else {
- inc -z $+(%,botflood.,$nick) 25
- }
- }
- else {
- inc -z $+(%,botflood.,$nick) 25
- }
- var %ticks $ticks
- set $+(%,twitter.,%ticks,.msgtype) $iif($chan,$iif($left($1,1) == @,msg $chan,notice $nick),msg $nick)
- if ($2) {
- if ($2 == help) {
- ;MARKED FOR REVISION -- add a help file
- ;.play -nm1 $nick TwitterHelp.txt 1300
- return
- }
- elseif ($2 != help) {
- if (($left($2,1) == $chr(35)) || ($left($2,1) == $chr(64)) || ($3 isalpha)) {
- set $+(%,twitter.,%ticks,.searching) true
- if ($gettok($2-,$numtok($2-,32),32) isnum) {
- set $+(%,twitter.,%ticks,.search) $gettok($2-,$+(1,-,$calc($numtok($2-,32) - 1)),32)
- set $+(%,twitter.,%ticks,.max) $gettok($2-,$numtok($2-,32),32)
- }
- elseif ($gettok($2-,$numtok($2-,32),32) !isnum) {
- set $+(%,twitter.,%ticks,.search) $2-
- set $+(%,twitter.,%ticks,.max) 3
- }
- sockopen $+(twitter.,%ticks) search.twitter.com 80
- }
- else {
- set $+(%,twitter.,%ticks,.user) $2
- set $+(%,twitter.,%ticks,.max) $iif($3,$3,3)
- sockopen $+(twitter.,%ticks) api.twitter.com 80
- }
- }
- }
- elseif ($2 == $null) {
- sockopen $+(twitter.,%ticks) api.twitter.com 80
- }
- }
- on $*:text:/.*twitter\.com.*\/status\/.*/Si:*: {
- $iif($istok(%youtubefetch,$chan,44),halt,noop)
- $iif($istok(%nolinks,$nick,44),halt,noop)
- if ($($+(%,botflood.,$nick),2)) {
- if ($($+(%,botflood.,$nick),2) >= 50) {
- ignore -u60 $address($nick,2)
- msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
- halt
- }
- elseif ($($+(%,botflood.,$nick),2) >= 40) {
- msg $chan $+($nick,$chr(44)) Please do not flood the bot.
- inc -z $+(%,botflood.,$nick) 20
- halt
- }
- else {
- inc -z $+(%,botflood.,$nick) 10
- }
- }
- else { inc -z $+(%,botflood.,$nick) 10 }
- var %i 1
- var %ticks $ticks
- while (%i <= $numtok($1-,32)) {
- if (*twitter.com* iswm $($+($,%i),2)) {
- ;add a check here to not parse same twice in a row?
- set $+(%,twitter.,%ticks,.msgtype) msg $iif($chan,$v1,$nick)
- set $+(%,twitter.,%ticks,.id) $gettok($remove($strip($($+($,%i),2)),http://,https://,twitter.com,mobile.,/#!),3,47)
- sockopen $+(twitter.,%ticks) api.twitter.com 80
- break
- }
- inc %i
- }
- }
- on *:sockopen:twitter*: {
- if ($($+(%,twitter.,$remove($sockname,twitter.),.searching),2) == true) {
- sockwrite -nt $sockname GET $+(/search.json?q=,$urlencode($($+(%,twitter.,$remove($sockname,twitter.),.search),2)),&rpp=,$($+(%,twitter.,$remove($sockname,twitter.),.max),2)) HTTP/1.1
- }
- else {
- if ($($+(%,twitter.,$remove($sockname,twitter.),.id),2) != $null) {
- sockwrite -nt $sockname GET $+(/1/statuses/show/,$($+(%,twitter.,$remove($sockname,twitter.),.id),2),.json) HTTP/1.1
- }
- elseif ($($+(%,twitter.,$remove($sockname,twitter.),.user),2) != $null) {
- sockwrite -nt $sockname GET $+(/1/statuses/user_timeline.json?exclude_replies=1,&screen_name=,$($+(%,twitter.,$remove($sockname,twitter.),.user),2),&count=,$($+(%,twitter.,$remove($sockname,twitter.),.max),2)) HTTP/1.1
- }
- else {
- sockwrite -nt $sockname GET /1/trends/1.json HTTP/1.1
- }
- }
- sockwrite -nt $sockname Host: $iif($($+(%,twitter.,$remove($sockname,twitter.),.searching),2) == true,search.twitter.com,api.twitter.com)
- sockwrite -nt $sockname $crlf
- }
- on *:sockread:twitter*: {
- if ($sockerr) {
- echo -a SOCKET ERROR: $sockname - $sockerr
- halt
- }
- else {
- sockread &t
- if (*"error":* iswm $bvar(&t,1-).text) {
- var %pos $bfind(&t,1,"error":)
- var %pos2 $bfind(&t,%pos,125)
- echo -a Error: $gettok($bvar(&t,%pos - %pos2).text,3,34)
- }
- if (*"created_at":* iswm $bvar(&t,1-).text) {
- var %x 1
- while (%x <= $wildtok($bvar(&t,1-).text,*"created_at":*,0,44)) {
- if ($calc(%x % 2) != 0) {
- var %s $wildtok($bvar(&t,1-).text,*"created_at":*,%x,44)
- var %d $noqt($gettok(%s,2-,58))
- echo -a %x - $tweettime(%d)
- }
- inc %x
- }
- }
- if (*"text":* iswm $bvar(&t,1-).text) {
- var %x 1
- while (%x <= $wildtok($bvar(&t,1-).text,*"text":*,0,44)) {
- var %pos $bfind(&t,1,$wildtok($bvar(&t,1-).text,*"text":*,%x,44))
- var %pos2 $bfind(&t,%pos,34 44)
- var %tweet $noqt($remove($bvar(&t,%pos - %pos2).text,"text":))
- echo -a %tweet
- inc %x
- }
- }
- if ((*"verified":* iswm $bvar(&t,1-).text) && ($($+(%,twitter.,$remove($sockname,twitter.),verified),2) == $null)) {
- var %pos $bfind(&t,1,"verified":)
- var %pos2 $bfind(&t,%pos,44 34)
- set $+(%,twitter.,$remove($sockname,twitter.),verified) $iif(*true* iswm $bvar(&t,%pos - %pos2).text,true,false)
- echo -a verified $($+(%,twitter.,$remove($sockname,twitter.),verified),2)
- }
- }
- }
- alias -l TweetTime {
- ;Input a date in $asctime format and this will return time from current date.
- return $duration($calc($ctime - $calc($ctime($remove($1-,+0000 $+ $chr(32))) - 14400)),2)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement