Sunday, April 25, 2010

Twitter Integration - Badges and Customization

As previously posted on this blog, HeroStats contains some basic Twitter integration features. Since that posting, some new features have been added. Most notably, you can choose to tweet when your character earns a badge. This is present in HeroStats 4.9.1.7 and above (including the upcoming 5.x stable builds).

You'll first need to set up Twitter integration as described in the previous blog post. You'll notice that the configuration screen looks a bit different than the screenshots in that post, though.


If you un-check the first checkbox, HeroStats won't send a tweet when you complete the Twitter setup. This is handy if you're setting this up more than once, and don't want to spam a bunch of setup tweets.

The second checkbox is for level-up tweets. In addition to the ability to turn it on or off completely with the checkbox, you can now choose a lower limit on the levels to tweet about. The default configuration is 10, so HeroStats won't tweet when your characters reach levels 2-9, but will tweet for every level 10 or higher. This helps to minimize the Twitter spam since those lowbie levels often go by very quickly.

The third checkbox is the new badge tweet functionality. It's turned off by default. If you check this box, then HeroStats will tweet when you earn a new badge. However, it will only check for new badges as often as the number of seconds listed (300 by default). This is again a measure to prevent large numbers of tweets. Completing a task force, picking up zone explore badges, or even just creating a new character often results in obtaining several badges all at once. Rather than posting a separate tweet for each one, HeroStats will tweet just once every five minutes, with a summary something like this:

Flame of Ebony (50 Magic Blaster on Victory) just earned City Official and 1 other badge in City of Heroes! #coh

The first badge you earned will be named, and then a count of how many other badges you've gotten since the last tweet.

Here's a sample of how my configuration looks once I've done the Twitter setup:


Finally, it is possible to customize the text of your tweets. I haven't yet provided a user interface for this, but it is possible as long as you aren't scared by a little XML. Make sure you've completed the Twitter setup steps, then shut down HeroStats. Go to your HeroStats directory and open the file called "HeroStatsConfig.xml" in a text editor. (This is probably not the default program - that's usually Internet Explorer - so you can't just double-click it.)

Inside that file you'll find two lines that look like this:

<twitterlevelupmsg>$name ($origin $archetype on $server) just reached level $level in $game! #coh</twitterlevelupmsg>

<twitterbadgemsg>$name ($origin $archetype on $server) just earned $badges in $game! #coh</twitterbadgemsg>

The level-up message is the bit between <twitterlevelupmsg> and </twitterlevelupmsg>, and the badge message is the bit between <twitterbadgemsg> and </twitterbadgemsg>.

There are several variables in these messages that you can use:

$level: This is the current level of your character. Note that the level-up tweet happens after you gain a level, so in that case this is your new level.

$name, $origin and $archetype: These work just like in the game client, showing the current character's name/origin/archetype.

$server: The server that your character is on.

$game: Either "City of Heroes" or "City of Villains" based on your character's archetype. (I'm not sure yet how I'm going to deal with this after Going Rogue allows switching sides...we'll see.)

$badges: The badges you've earned since the last badge tweet. This won't include every badge name, but rather the first badge you earned in that time plus a count of additional badges. Examples: "Whitecap" (for just one badge) or "Whitecap and 1 other badge" (for 2 badges) or "Whitecap and 2 other badges" (for 3 badges).

You can modify this however you like, but keep in mind the Twitter 140 character limit! If your message exceeds that after replacing the $ variables, then your tweet will fail. This will be reported in the HSLogFile if your debug level is set high enough. Once you're done modifying the message, save the file and start up HeroStats - your next tweet should use the new message!

33 comments:

Leandro said...

Can you add a "Send Twitter update now" option to the menu (under "Send Badge Data") to force a message to go out? That would allow a player to set a really long Twitter update frequency and use the menu to send the badge data on demand. When I'm running around getting exploration badges, I'd rather they didn't show up until I'm done getting them all, while other badges (such as TF badges) I'd want to appear immediately.

Any plans for Facebook integration in the future?

Leandro said...

It should also be possible to send a regular Tweet directly from COH by using self-tells. A bind such as:

/bind p beginchat "/tell $name, Tweet: "

Would put /tell $name, Tweet: in the chat bar when the key P was pressed, and then it should be possible to capture the self-tweet in order to post it; it would look like this in the logs:

[Tell] Doctor Leo: Tweet: sample tweet
[Tell] -->Doctor Leo: Tweet: sample tweet

Skip Franklin said...

Thanks for the comments, Leandro.

I believe Send Badge Data should also force updates to Twitter. I tried it out and it's working OK for me.

I also fixed the badge selection bug - you should no longer see tweets if you select a badge, only if you earn one.

I do not plan to add Facebook integration. It's simple enough to push tweets to Facebook updates. Although if someone else would like to code it, that would be fine!

As for self-tells, I'm not sure I want to get into the business of maintaining that much stuff in the HeroStats program. Again, if someone else would like to add it, I could be convinced to include it in a future build, but I don't plan to code such a thing myself.

Leandro said...

Badge tweeting is ignoring the # of seconds between tweets. I set it to 3600 seconds (one hour) yet it's tweeting every 5 minutes anyway.

Anonymous said...
This comment has been removed by a blog administrator.
Syll0228vesterGetchel said...
This comment has been removed by a blog administrator.
Skip Franklin said...

Actually, it's not ignoring the setting - it's tweeting when you log out, which is by design. The problem is actually that the scanner thinks you're logging out. This is happening to many people and I'm not able to figure out why just yet - see the "Issue 17 difficulties" post on the main HeroStats page. You're actually one of the lucky ones. Many people aren't seeing character information at all.

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
天光天光 said...
This comment has been removed by a blog administrator.
寶堅強皓 said...
This comment has been removed by a blog administrator.
DaltonS_Beve said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
兆以 said...
This comment has been removed by a blog administrator.
智宜 said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.