Twitter Latest Bot Script

By GrimReaper on Mar 19, 2011

Basically all this script does is gather your latest tweet.. There is an option to store your Twitter name to your nick..

Syntax:

!tlatest add (Stores the twittername)
!tlatest del (Deletes your stored twittername)
!tlatest (Searches for the twittername you specified)
!tlatest (Searches for your latest tweet)

on *:TEXT:!tlatest*:#: {
  .sockclose tlatest
  unset %Tlatestinfo %Tlatesthalt %tcontent %ttimestamp %tsentvia
  if ($2 == add) {
    if (!$3) { msg $chan * Error: Incorrect syntax: !tlatest add <twitter name> }
    elseif ($ini(Twitter.ini,Twitternames,$nick)) { msg $chan Your nick is already saved within my Database. Please use !tlatest on it's own. }
    else {
      writeini Twitter.ini Twitternames $nick $3-
      msg $chan Your name has been stored in my Database. You may continue to use !tlatest on it's own.
    }
  }
  if ($2 == del) {
    if (!$3) { msg $chan * Error: Please say your twitter name when using this command. }
    elseif (!$ini(Twitter.ini,Twitternames,$nick)) { msg $chan Your nick is not within my Database. Please use !tlatest add <Twitter name> OR !Tlatest <Twitter name>. }
    else {
      remini Twitter.ini Twitternames $nick
      msg $chan Twitter info for $3 has been removed from my Database.
    }
  }
  elseif (!$ini(Twitter.ini,Twitternames,$nick)) && (!$2) {
    msg $chan Sorry $+($nick,$chr(44)) Your Twitter name has not been stored in my Database. Please add it using !tlatest add <Twitter name>
  }
  elseif ($ini(Twitter.ini,Twitternames,$nick)) && (!$2) {
    sockopen tlatest twitter.com 80
    sockmark tlatest msg $chan $readini(Twitter.ini,Twitternames,$nick)
  }
  elseif ($sock(tlatest)) { .sockclose tlatest | msg $chan Please try again. }
  else {
    sockopen tlatest twitter.com 80
    sockmark tlatest msg $chan $2
  }
}
on *:SOCKOPEN:tlatest: {
  if ($sockerr) { $gettok($sock(tlatest).mark,1-2,32) Error connecting to server. }
  else {
    var %a = sockwrite -n $sockname
    %a GET / $+ $gettok($sock(tlatest).mark,3,32) HTTP/1.0
    %a Host: twitter.com
    %a $crlf
  }
}
on *:SOCKREAD:tlatest: {
  var %tlatest | sockread -fn %tlatest
  if (<span class="entry-content"> isin %tlatest) && (!%tcontent) { set %tcontent on | set %Tlatestinfo $addtok(%Tlatestinfo,$remove($htmlfree(%tlatest),$chr(9)),32) }
  elseif (<span class="published timestamp" isin %tlatest) && (!%ttimestamp) { set %ttimestamp on | set %Tlatestinfo $addtok(%Tlatestinfo,Sent: $htmlfree(%tlatest),32) }
  elseif (<span>via <a href=" isin %tlatest) && (!%tsentvia) { 
    set %tsentvia on
    set %Tlatestinfo $addtok(%Tlatestinfo,Sent via: $remove($htmlfree(%tlatest),via),32)
    $gettok($sock(tlatest).mark,1-2,32) $+(,$gettok($sock(tlatest).mark,3,32)) $+ 's Latest tweet: $replace(%Tlatestinfo,&lt;,$chr(60),&gt;,$chr(62),&quot;,$chr(34))
    .sockclose $sockname 
  }
}

alias htmlfree { return $regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)|&[^;]+;|       /g,$null) }

Comments

Sign in to comment.
GrimReaper   -  Oct 30, 2012

@imperialturkey Your comment wasn't really needed, I haven't updated this code because I don't have the time to. If you want to post something like that. Post it on your own profile, Not on someone else's code snippet.

 Respond  
imperialturkey   -  Oct 18, 2012

yeah sorry..

 Respond  
AllTimeMarr   -  Nov 22, 2011

Oh! haha, i'm not that good in mirc scripting, i just tried fixing it :p

 Respond  
_Dean_   -  Oct 22, 2011

AllTimeMarr, you dont need to use $null to replace it
you can use simply

alias htmlfree { return $regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)|&[^;]+;|/g,) }

in fact the $htmlfree can be just

return $regsubex($1-,/<[^>]+>/g,)

or use

return $regsubex($1-,/<[^>]+>|\t/g,)

to replace tab too

 Respond  
jasonh   -  Oct 22, 2011

thank you, AllTimeMarr

 Respond  
AllTimeMarr   -  Jul 09, 2011

If you're having the space problem;

Delete the spaces between | and /g in the last line:

"alias htmlfree { return $regsubex($1-,/(^[^<]>|<[^>]>|<[^>]*$)|&[^;]+;| /g,$null) }"

should be:

"alias htmlfree { return $regsubex($1-,/(^[^<]>|<[^>]>|<[^>]*$)|&[^;]+;|/g,$null) }"

 Respond  
Fawkes   -  Jun 16, 2011

the space not show.. confused..

 Respond  
irchainscriptz   -  Apr 01, 2011

Would be nice to have one like this for facebook LOL

 Respond  
chrisx1974   -  Apr 01, 2011

How do i get this to work??? I try several addons or snipets or whatever to have automatic my tweets into an irc channel... none of all worked... i grab the codes, load them into my irc script... nothing happend!?? Please help :-)

 Respond  
Callumlord   -  Mar 26, 2011

Like if you type something in it does not put the spaces between the words so it looks:

YehtodayIgotmyiPad

Should be

Yeh today I got my iPad

 Respond  
GrimReaper   -  Mar 26, 2011

hmm, bitmoose, Could you give me an example of what you mean by "spaces between the words"

 Respond  
Callumlord   -  Mar 26, 2011

Nice Script :D Thanks. Only problem has been pointed out. :)

 Respond  
GrimReaper   -  Mar 26, 2011

I will have a look at it and find out what is wrong, Then update.. Sorry, I don't know why it doesn't appear to be working, It work's on my bot with no problems :s

 Respond  
bitmoose   -  Mar 25, 2011

Doesn't seem to put spaces in between the words...

 Respond  
bps   -  Mar 20, 2011

hi, at least for me it doesn't work :)

 Respond  
GrimReaper   -  Mar 19, 2011

Thanks Napa.. I would use the API, But I preferred this way for some reason, Why I didn't add this to the last post I don't know.. lol.. Just one of those moments I suppose >_>

 Respond  
GrimReaper   -  Mar 19, 2011

I always seem to forget the htmlfree alias. >_< Edited now and added

 Respond  
napa182   -  Mar 19, 2011

Nice snippet GrimReaper, but it would be better to use Twitters API.

 Respond  
_Dean_   -  Mar 19, 2011

i guess you forgot the htmlfree alias...

    set %Tlatestinfo $addtok(%Tlatestinfo,Sent via: $remove($htmlfree(%tlatest),via),32)
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.