Created
November 30, 2010 02:53
-
-
Save MikeGrace/721065 to your computer and use it in GitHub Desktop.
Example Twitter addon using KRL, subscribing to the stream_item_clicked event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruleset a60x436 { | |
meta { | |
name "example-staf-app" | |
description << | |
example-staf-app | |
>> | |
author "Mike Grace" | |
logging on | |
} | |
rule parity_of_users_twitter_id { | |
select when web stream_item_clicked | |
pre { | |
userId = event:param("userId"); | |
target = event:param("target"); | |
lastDigit = "#{userId}".replace(re/.*(.$)/,"$1"); | |
evenDigit = "#{lastDigit}".replace(re/[0,2,4,6,8]/,"even"); | |
parity = (evenDigit eq "even") => "even" | "odd"; | |
parityNotice =<< | |
<p>This users Twitter ID is <b>#{parity}</b></p> | |
>>; | |
} | |
{ | |
append(target, parityNotice); | |
emit <| | |
checkin("a60x436", target); | |
|>; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment