Advertisement
illpastethat

Twitter unfinished chromatic

Aug 4th, 2013
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 6.08 KB | None | 0 0
  1. ;Twitter Script (Timeline & Tweets) v1.0 [[Beta Unfinished Version]]
  2. ;Made by nick1 on May 07 2012
  3. ;Last edit May 07 2012
  4. ;2DO everything
  5.  
  6. ;http://api.twitter.com/1/statuses/user_timeline.json?screen_name=USER&count=3
  7. ;http://search.twitter.com/search.json?q=blue%20angels&rpp=MAX
  8. ;http://api.twitter.com/1/statuses/show/TheLongAssIDHere.json
  9. ;https://api.twitter.com/1/trends/23424977.json -- 23424977 is US and 1 is global
  10.  
  11. ;raw 408:*: msg $2 $remove($strip($13-),$chr(9))
  12.  
  13. off $*:text:/^[!@.](twitter|tweet|hashtag|trending|tt|trends)(\s|$)/Si:*: {
  14.   tokenize 32 $strip($1-)
  15.   $iif($chan == #rsbot,halt,noop)
  16.   if ($($+(%,botflood.,$nick),2)) {
  17.     if ($($+(%,botflood.,$nick),2) >= 50) {
  18.       ignore -u60 $address($nick,2)
  19.       msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
  20.       halt
  21.     }
  22.     elseif ($($+(%,botflood.,$nick),2) >= 40) {
  23.       msg $chan $+($nick,$chr(44)) Please do not flood the bot.
  24.       inc -z $+(%,botflood.,$nick) 20
  25.       halt
  26.     }
  27.     else {
  28.       inc -z $+(%,botflood.,$nick) 25
  29.     }
  30.   }
  31.   else {
  32.     inc -z $+(%,botflood.,$nick) 25
  33.   }
  34.   var %ticks $ticks
  35.   set $+(%,twitter.,%ticks,.msgtype) $iif($chan,$iif($left($1,1) == @,msg $chan,notice $nick),msg $nick)
  36.   if ($2) {
  37.     if ($2 == help) {
  38.       ;MARKED FOR REVISION -- add a help file
  39.       ;.play -nm1 $nick TwitterHelp.txt 1300
  40.       return
  41.     }
  42.     elseif ($2 != help) {
  43.       if (($left($2,1) == $chr(35)) || ($left($2,1) == $chr(64)) || ($3 isalpha)) {
  44.         set $+(%,twitter.,%ticks,.searching) true
  45.         if ($gettok($2-,$numtok($2-,32),32) isnum) {
  46.           set $+(%,twitter.,%ticks,.search) $gettok($2-,$+(1,-,$calc($numtok($2-,32) - 1)),32)
  47.           set $+(%,twitter.,%ticks,.max) $gettok($2-,$numtok($2-,32),32)
  48.         }
  49.         elseif ($gettok($2-,$numtok($2-,32),32) !isnum) {
  50.           set $+(%,twitter.,%ticks,.search) $2-
  51.           set $+(%,twitter.,%ticks,.max) 3
  52.         }
  53.         sockopen $+(twitter.,%ticks) search.twitter.com 80
  54.       }
  55.       else {
  56.         set $+(%,twitter.,%ticks,.user) $2
  57.         set $+(%,twitter.,%ticks,.max) $iif($3,$3,3)
  58.         sockopen $+(twitter.,%ticks) api.twitter.com 80
  59.       }
  60.     }
  61.   }
  62.   elseif ($2 == $null) {
  63.     sockopen $+(twitter.,%ticks) api.twitter.com 80
  64.   }
  65. }
  66.  
  67. on $*:text:/.*twitter\.com.*\/status\/.*/Si:*: {
  68.   $iif($istok(%youtubefetch,$chan,44),halt,noop)
  69.   $iif($istok(%nolinks,$nick,44),halt,noop)
  70.   if ($($+(%,botflood.,$nick),2)) {
  71.     if ($($+(%,botflood.,$nick),2) >= 50) {
  72.       ignore -u60 $address($nick,2)
  73.       msg $chan $+($nick,$chr(44)) You have been put on ignore for 60secs for abusing the bot.
  74.       halt
  75.     }
  76.     elseif ($($+(%,botflood.,$nick),2) >= 40) {
  77.       msg $chan $+($nick,$chr(44)) Please do not flood the bot.  
  78.       inc -z $+(%,botflood.,$nick) 20
  79.       halt
  80.     }
  81.     else {
  82.       inc -z $+(%,botflood.,$nick) 10
  83.     }
  84.   }
  85.   else { inc -z $+(%,botflood.,$nick) 10 }
  86.   var %i 1
  87.   var %ticks $ticks
  88.   while (%i <= $numtok($1-,32)) {
  89.     if (*twitter.com* iswm $($+($,%i),2)) {
  90.       ;add a check here to not parse same twice in a row?
  91.       set $+(%,twitter.,%ticks,.msgtype) msg $iif($chan,$v1,$nick)
  92.       set $+(%,twitter.,%ticks,.id) $gettok($remove($strip($($+($,%i),2)),http://,https://,twitter.com,mobile.,/#!),3,47)
  93.       sockopen $+(twitter.,%ticks) api.twitter.com 80
  94.       break
  95.     }
  96.     inc %i
  97.   }
  98. }
  99.  
  100. on *:sockopen:twitter*: {
  101.   if ($($+(%,twitter.,$remove($sockname,twitter.),.searching),2) == true) {
  102.     sockwrite -nt $sockname GET $+(/search.json?q=,$urlencode($($+(%,twitter.,$remove($sockname,twitter.),.search),2)),&rpp=,$($+(%,twitter.,$remove($sockname,twitter.),.max),2)) HTTP/1.1
  103.   }
  104.   else {
  105.     if ($($+(%,twitter.,$remove($sockname,twitter.),.id),2) != $null) {
  106.       sockwrite -nt $sockname GET $+(/1/statuses/show/,$($+(%,twitter.,$remove($sockname,twitter.),.id),2),.json) HTTP/1.1
  107.     }
  108.     elseif ($($+(%,twitter.,$remove($sockname,twitter.),.user),2) != $null) {
  109.       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
  110.     }
  111.     else {
  112.       sockwrite -nt $sockname GET /1/trends/1.json HTTP/1.1
  113.     }
  114.   }
  115.   sockwrite -nt $sockname Host: $iif($($+(%,twitter.,$remove($sockname,twitter.),.searching),2) == true,search.twitter.com,api.twitter.com)
  116.   sockwrite -nt $sockname $crlf
  117. }
  118.  
  119. on *:sockread:twitter*: {
  120.   if ($sockerr) {
  121.     echo -a SOCKET ERROR: $sockname - $sockerr
  122.     halt
  123.   }
  124.   else {
  125.     sockread &t
  126.     if (*"error":* iswm $bvar(&t,1-).text) {
  127.       var %pos $bfind(&t,1,"error":)
  128.       var %pos2 $bfind(&t,%pos,125)
  129.       echo -a Error: $gettok($bvar(&t,%pos - %pos2).text,3,34)
  130.     }
  131.     if (*"created_at":* iswm $bvar(&t,1-).text) {
  132.       var %x 1
  133.       while (%x <= $wildtok($bvar(&t,1-).text,*"created_at":*,0,44)) {
  134.         if ($calc(%x % 2) != 0) {
  135.           var %s $wildtok($bvar(&t,1-).text,*"created_at":*,%x,44)
  136.           var %d $noqt($gettok(%s,2-,58))
  137.           echo -a %x - $tweettime(%d)
  138.         }
  139.         inc %x
  140.       }
  141.     }
  142.     if (*"text":* iswm $bvar(&t,1-).text) {
  143.       var %x 1
  144.       while (%x <= $wildtok($bvar(&t,1-).text,*"text":*,0,44)) {
  145.         var %pos $bfind(&t,1,$wildtok($bvar(&t,1-).text,*"text":*,%x,44))
  146.         var %pos2 $bfind(&t,%pos,34 44)
  147.         var %tweet $noqt($remove($bvar(&t,%pos - %pos2).text,"text":))
  148.         echo -a %tweet
  149.         inc %x
  150.       }
  151.     }
  152.     if ((*"verified":* iswm $bvar(&t,1-).text) && ($($+(%,twitter.,$remove($sockname,twitter.),verified),2) == $null)) {
  153.       var %pos $bfind(&t,1,"verified":)
  154.       var %pos2 $bfind(&t,%pos,44 34)
  155.       set $+(%,twitter.,$remove($sockname,twitter.),verified) $iif(*true* iswm $bvar(&t,%pos - %pos2).text,true,false)
  156.       echo -a verified $($+(%,twitter.,$remove($sockname,twitter.),verified),2)
  157.     }
  158.   }
  159. }
  160.  
  161. alias -l TweetTime {
  162.   ;Input a date in $asctime format and this will return time from current date.
  163.   return $duration($calc($ctime - $calc($ctime($remove($1-,+0000 $+ $chr(32))) - 14400)),2)
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement