Fancier factorbot
parent
6b92fc2aa9
commit
e94d38c31b
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
! Load the HTTP server first (contrib/httpd/load.factor).
|
! Load the HTTP server first (contrib/httpd/load.factor).
|
||||||
|
|
||||||
USING: errors generic hashtables html http io kernel math memory
|
USING: errors generic hashtables help html http io kernel math
|
||||||
namespaces parser prettyprint sequences strings threads words ;
|
memory namespaces parser prettyprint sequences strings threads
|
||||||
|
words ;
|
||||||
IN: factorbot
|
IN: factorbot
|
||||||
|
|
||||||
SYMBOL: irc-stream
|
SYMBOL: irc-stream
|
||||||
|
@ -77,22 +78,36 @@ M: ping handle-irc ( line -- )
|
||||||
: multiline-respond ( string -- )
|
: multiline-respond ( string -- )
|
||||||
<string-reader> lines [ respond ] each ;
|
<string-reader> lines [ respond ] each ;
|
||||||
|
|
||||||
|
: object-href
|
||||||
|
"http://factorcode.org" swap browser-link-href append ;
|
||||||
|
|
||||||
|
: not-found ( str -- )
|
||||||
|
"Sorry, I couldn't find anything for " swap append respond ;
|
||||||
|
|
||||||
IN: factorbot-commands
|
IN: factorbot-commands
|
||||||
|
|
||||||
: see ( text -- )
|
: see ( text -- )
|
||||||
dup vocabs [ vocab ?hash ] map-with [ ] subset
|
all-words [ word-name = ] subset-with
|
||||||
dup empty? [
|
dup empty? [
|
||||||
drop
|
drop
|
||||||
"Sorry, I couldn't find anything for " swap append respond
|
not-found
|
||||||
] [
|
] [
|
||||||
nip [
|
nip [
|
||||||
dup synopsis " -- http://factorcode.org"
|
dup synopsis " -- "
|
||||||
rot browser-link-href append3 respond
|
rot object-href append3 respond
|
||||||
] each
|
] each
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
: memory ( text -- )
|
||||||
|
drop [ room. ] string-out multiline-respond ;
|
||||||
|
|
||||||
|
: search ( text -- )
|
||||||
|
search-help dup empty? [
|
||||||
|
not-found
|
||||||
|
] [
|
||||||
|
first first dup article-title
|
||||||
|
" -- " rot <link> object-href append3 respond
|
||||||
|
] if ;
|
||||||
|
|
||||||
: quit ( text -- )
|
: quit ( text -- )
|
||||||
drop speaker get "slava" = [ disconnect ] when ;
|
drop speaker get "slava" = [ disconnect ] when ;
|
||||||
|
|
||||||
: memory ( text -- )
|
|
||||||
drop [ room. ] string-out multiline-respond ;
|
|
||||||
|
|
Loading…
Reference in New Issue