Created
March 30, 2013 10:24
-
-
Save gchiu/5276233 to your computer and use it in GitHub Desktop.
greet new people
This file contains 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
who-is-online: func [ message-id | |
/silent | |
/local out page username userid len newbies addressees | |
][ | |
addressees: copy "" | |
len: length? visitors | |
out: copy [] | |
newbies: copy [] | |
page: to string! read html-url | |
parse page [ | |
some [ | |
thru "chat.sidebar.loadUser(" copy userid some id-rule thru {("} copy username to {")} | |
( trim/all username | |
append out username | |
if not find visitors username [ | |
append visitors username | |
append newbies username | |
] | |
) | |
] | |
to end | |
] | |
either empty? out [ | |
reply message-id "can not parse the page for users" | |
][ | |
either not silent [ | |
reply message-id form out | |
][ | |
; silent scan has detected new users - so let's greet them | |
if not empty? newbies [ | |
foreach person newbies [ | |
append addressees ajoin [ "@" person " " ] | |
] | |
speak ajoin [ addressees " " greet-message ] | |
] | |
] | |
if len < length? visitors [ | |
save visitors-file visitors | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment