Skip to content

Instantly share code, notes, and snippets.

@gchiu
Created March 30, 2013 10:24
Show Gist options
  • Save gchiu/5276233 to your computer and use it in GitHub Desktop.
Save gchiu/5276233 to your computer and use it in GitHub Desktop.
greet new people
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