Twitter Bot

By PowerScripters on Jan 09, 2010

The Twitter Bot reads the latest News of a User.
You don't need to configure anything.

You can change the maximum Post per Data | /set %twitter-reads

Have Fun

Screenshots
Image

Image

alias twitter-connection { sockopen twitter twitter.com 80 }
on *:SOCKOPEN:twitter:{

  ; connection
  sockwrite -n $sockname GET %twitter-connection HTTP/1.1

  ; Write Connection Details
  sockwrite -n $sockname Host: twitter.com
  sockwrite -n $sockname User-Agent: IRCSpider/mIRC $version
  sockwrite -n $sockname $crlf 

}
on *:SOCKREAD:twitter:{
var %mirc.temp 0
  sockread %mirc.temp
  if (<span class="entry-content"> isin %mirc.temp) {
if ((http://twitter.com/ !isin %mirc.temp) && (tweet-url !isin %mirc.temp) && (%twitter-maxposts != $iif(!%twitter-reads,3,%twitter-reads))) {
   msg %twitter-channel  00,02Twitter: ( $+ $remove(%twitter-connection,/) $+ ) $replace($remove(%mirc.temp,<span class="entry-content">,</span>),&gt;,>,&lt;,<,&amp;,&)
   inc %twitter-maxposts
}
  }
}
on *:SOCKCLOSE:twitter:{ unset %twitter-* }
// [c] janosch_ , don't miss updates @ !twitter <rattazongg> ;)
on *:TEXT:!twitter*:#:{
  unset %twitter-maxposts
  if (!$2) { msg $chan Syntax: !twitter <username> }
  else { set %twitter-connection / $+ $2 | set %twitter-channel $chan | twitter-connection }
}

## PowerScripters for President

Comments

Sign in to comment.
RIcko   -  Jun 30, 2012

ALT + R then post it into remotes.

about the script, its obviously not working nor returning any results.

 Respond  
lingroup   -  Jun 30, 2012

100% newbie here, can someone explain how to implement this? I just need a basic bot that reads off tweets as they come into the feed. Thanks

 Respond  
bps   -  Mar 19, 2011

Hi!

Well it works pretty well, but with some accounts it doesn't show any result and all twits with urls are also missing. Good Job anyway

 Respond  
Shiny   -  Feb 03, 2010

lol PowerScripters is a CLAN!

 Respond  
Jethro   -  Feb 03, 2010

One minute shiny appears he doesn't know much about MSL, the next he's going at sockets. What's going on here? Am I being deceived or deluded?

 Respond  
diamondandy   -  Feb 02, 2010

Newbie here, where in the script editor do i post this?

 Respond  
uncled1023   -  Jan 18, 2010

Hey, when i type !twitter into the chan my bots on, it doesnt work...

 Respond  
PowerScripters   -  Jan 16, 2010

@MagicRevealer09 Type: !twitter

 Respond  
MagicRevealer09   -  Jan 16, 2010

How do I use it?

 Respond  
PowerScripters   -  Jan 09, 2010

Ok LordLawnmower, i fix this now, i dont know that sockread defines %mirc.temp as global.

THanks.

 Respond  
FordLawnmower   -  Jan 09, 2010

Okey :)
However, if you are creating an if statement just to force the else when certain conditions don't exist, you should just use !isin instead of isin and != instead of ==.

Like this:

if ((http://twitter.com/ !isin %mirc.temp) && (tweet-url !isin %mirc.temp) && (%twitter-maxposts != $iif(!%twitter-reads,3,%twitter-reads))) {
   msg %twitter-channel  00,02Twitter: ( $+ $remove(%twitter-connection,/) $+ ) $replace($remove(%mirc.temp,<span class="entry-content">,</span>),&gt;,>,&lt;,<,&amp;,&)
   inc %twitter-maxposts
}

By the way, you still left the variable %mirc.temp set. If you don't declare the variable as local before you sockread to it, it's automatically declared as global.

This is the proper way to do it with a local variable.

var %mirc.temp | sockread %mirc.temp 
 Respond  
PowerScripters   -  Jan 09, 2010

@FordLawnmower:

Fixed all of those. - Sure, i want to use POST first, to insert Twitter-Posts, but after that i decided to use GET, but i forget to change the COnnection Details.
/noop is just for no-operation, replaced it now with /unset %twitter-*

The empty brackets are now for /noop | the same ... - it works so, and thats fine. :o

Forgive Me, I uploaded that ugly Code, thanks for your Command. :)

 Respond  
FordLawnmower   -  Jan 09, 2010

What on earth is all of this for?

  ; connection
  sockwrite -n $sockname GET %twitter-connection HTTP/1.1

  ; Write Connection Details
  sockwrite -n $sockname Host: twitter.com
  sockwrite -n $sockname User-Agent: IRCSpider/mIRC $version
  sockwrite -n $sockname Accept: *.*, */*
  sockwrite -n $sockname Referer: $server
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname $crlf 

On occasion you may need User Agent:, Referer: is never needed, Content-Type: is for POST not GET as is Accept:, and Connection: is not needed here.
All that is needed here is Host: and GET the rest is just slowing down the script.

  ; connection
  sockwrite -n $sockname GET %twitter-connection HTTP/1.1
  sockwrite -n $sockname Host: twitter.com
  sockwrite -n $sockname $crlf 

Also, did you realize that you pointed an if at empty brackets { }

if ((http://twitter.com/ isin %mirc.temp) || (tweet-url isin %mirc.temp) || (%t = $iif(%twitter.reads == $null,3,%twitter.reads))) { }

What is the point of this?

on *:SOCKCLOSE:twitter:{ /noop }

You didn't unset your variables either.

Sorry if it seems like I'm ranting on your script, I'm sure you worked hard on it, please forgive me :((

I'll stop now because I see several other things.

 Respond  
Shinybot   -  Jan 09, 2010

yeah 10/10

 Respond  
Master-Of-Death   -  Jan 09, 2010

brilliant script! 8/10

 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.