Hello,

I've got a twitter script and it shows the last tweet and stats.
This is how it shows a last tweet:

14.15.40 <DJ-Serv> (Last tweet) @riccremer Hihihi oke maar ik moet wel van m'n pappie voor het donker thuis zijn hoor :$

I'd like to have the mentions (the names starting with @, in thic case '@riccremer') colored. Only I don't know how.

It should be like this: 14.15.40 <DJ-Serv> (Last tweet) @riccremer Hihihi oke maar ik moet wel van m'n pappie voor het donker thuis zijn hoor :$

I also like to have the same with the hashtags, #words #starting #with #this #char.

Can anyone help?

Script:
Code:
on *:CONNECT: {
  var %twitter_file  $+(twitter_,$network)
  hmake %twitter_file 100
  if ($isfile($+(%twitter_file,.dat))) { hload %twitter_file $+(%twitter_file,.dat) }
}
ON *:DISCONNECT: {
  var %twitter_file  $+(twitter_,$network)
  if ($hget(%twitter_file)) { hsave -o %twitter_file $+(%twitter_file,.dat) }
}

on *:TEXT:.twitter*:#: {
  unset %t_*
  set %t_nick $nick
  set %t_chan $chan
  set %t_network $network
  set %t_2 $2
  set %t_3 $3
  if ($3 == s) || ($3 == stats) || ($3 == status) { set %t_3 stats | set %t_info_req ON }
  if ($3 == last) || ($3 == time) { set %t_3 last | set %t_info_req ON }

  if $2 == $null {
    msg $chan  $+ %sc2 $+ ( $+ %sc $+ Twitter $+ %sc2 $+ ) Please specify a command, ex.:
    msg $chan  $+ %sc2 $+ ( $+ %sc $+ Twitter $+ %sc2 $+ ) .twitter  $+ %sc2 $+ username/ircnick,  $+ %sc2 $+ username/ircnick stats,  $+ %sc2 $+ register username/ircnick or  $+ %sc2 $+ remove username/ircnick
    msg $chan  $+ %sc2 $+ ( $+ %sc $+ Twitter $+ %sc2 $+ ) The command  $+ %sc2 $+ register will associate your current IRC Nickname with the given twitter username.  $+ %sc2 $+ Remove will remove the association and  $+ %sc2 $+ stats will show the statics of the given twitter username.
    halt
  }

  if (%t_2 != $null) {
    var %twitter_reg $($+(twitter_,$network))
    if (%t_2 == register) && (%t_3 != $null) {
      hadd -m %twitter_reg %t_nick %t_3
      .msg %t_nick You are now linked to %t_3
      set %t_2 $hget(%twitter_reg,%t_nick)
      halt
    }
    if (%t_2 == remove) && (%t_3 != $null) {
      hdel %twitter_reg %t_nick
      .msg %t_nick You twitter association was removed
      twitter_cleanup
      halt
    }
    if ($hget(%twitter_reg,%t_2) != $null ) {
      set %t_2 $hget(%twitter_reg,%t_2)
    }
    set %t_url $+(/statuses/user_timeline.xml?screen_name=,%t_2)
  }
  sockopen twitter www.twitter.com 80
}

on *:sockopen:twitter: {
  sockwrite -n $sockname GET %t_url
  sockwrite -n $sockname www.twitter.com
}

on *:sockread:twitter: {
  sockread %t_temp
  if (<id> isin %t_temp) && (%t_id == $null) set %t_id $remove(%t_temp,<id>,</id>,$chr(9),$chr(32))
  if (<name> isin %t_temp) && (%t_name == $null) set %t_name $remove(%t_temp,<name>,</name>,$chr(9))
  if (<screen_name> isin %t_temp) && (%t_screen_name == $null) set %t_screen_name $remove(%t_temp,<screen_name>,</screen_name>,$chr(9),$chr(32))
  if (<location> isin %t_temp) && (%t_location == $null) set %t_location $remove(%t_temp,<location>,</location>,$chr(9),$chr(32))
  if (<description> isin %t_temp) set %t_description $remove(%t_temp,<description>,</description>,$chr(9))

  if (<followers_count> isin %t_temp) && (%t_followers_count == $null) set %t_followers_count $remove(%t_temp,<followers_count>,</followers_count>,$chr(9),$chr(32))
  if (<friends_count> isin %t_temp) && (%t_friends_count == $null) set %t_friends_count $remove(%t_temp,<friends_count>,</friends_count>,$chr(9),$chr(32))
  if (<favourites_count> isin %t_temp) && (%t_favourites_count == $null) set %t_favourites_count $remove(%t_temp,<favourites_count>,</favourites_count>,$chr(9),$chr(32))
  if (<time_zone> isin %t_temp) && (%t_time_zone == $null) set %t_time_zone $remove(%t_temp,<time_zone>,</time_zone>,$chr(9),$chr(32))
  if (<statuses_count> isin %t_temp) && (%t_statuses_count == $null) set %t_statuses_count $remove(%t_temp,<statuses_count>,</statuses_count>,$chr(9),$chr(32))

  if (<status> isin %t_temp) inc %t_i
  if (<created_at> isin %t_temp) set %t_created_at $remove(%t_temp,<created_at>,</created_at>,$chr(9))
  if (<text> isin %t_temp) set $+(%,t_text,%t_i) $remove(%t_temp,<text>,</text>,$chr(9))
  if (<source> isin %t_temp) set $+(%,t_source,%t_i) $remove(%t_temp,<source>,</source>,$chr(9))
  if (<error> isin %t_temp) set %t_error ON
}


on *:sockclose:twitter: {
  if (%t_error == ON) {
    msg %t_chan  $+ %sc2 $+ ( $+ %sc $+ Twitter $+ %sc2 $+ ) Sorry, %t_2 wasn't found.
    twitter_cleanup
  }
  if (%t_error == $null) {
    if (%t_3 == bio) {
      if %t_description == $null {
        msg %t_chan test ik ben leeg.
      }
      else {
        msg %t_chan  $+ %sc2 $+ ( $+ %sc $+ Biography $+ %sc2 $+ ) %t_description
        halt
      }
    }
    if (%t_info_req != ON) msg %t_chan  $+ %sc2 $+ ( $+ %sc $+ Last tweet $+ %sc2 $+ ) $replace(%t_text1,&#235;,ë)
    if (%t_3 == stats) msg %t_chan  $+ %sc2 $+ ( $+ %sc $+ Twitter $+ %sc2 $+ ) %t_screen_name is  $+ %sc2 $+ following  $+ %sc $+ %t_friends_count $+  people, is having  $+ %sc $+ %t_followers_count $+   $+ %sc2 $+ follower(s) and has posted  $+ %sc $+ %t_statuses_count $+   $+ %sc2 $+ tweet(s).
  }
  twitter_cleanup
}

alias twitter_cleanup {
  unset %t_*
}





EDIT:
I just found something that doesnt work well. Maybe someone can help with this to? The script does NOT get the LATEST updates. It gets ALL updates. That's not a huge problem, but it is with the following:

if (<description> isin %t_temp) set %t_description $remove(%t_temp,<description>,</description>,$chr(9))



Here it gets the information 'description' from the .xml file (example: http://twitter.com/statuses/user_timeline/riccremer.xml)

But the .xml file contains not 1 'description', but more and now the script doesn't get the FIRST 'decsription' in the .xml file, it gets the one wayyyy down the page. (Sorry for my bad english. It just needs to get the first 'description' of the .xml file')

Someone can help with this too? I hope so! The decsription part is used at


if %t_description == $null {
msg %t_chan test ik ben leeg.
}
else {
msg %t_chan  $+ %sc2 $+ ( $+ %sc $+ Biography $+ %sc2 $+ ) %t_description
halt
}

Last edited by DuXxXieJ; 12/12/10 01:51 PM.

Squee whenever a squee squee's. Squee whenever a squee does not squee.