rebolbot icon indicating copy to clipboard operation
rebolbot copied to clipboard

Command to have bots change their avatars

Open hostilefork opened this issue 11 years ago • 14 comments

Ability available to room owners. Syntax probably just avatar url!

@RebolBot avatar http://example.com/foo.png

hostilefork avatar Mar 19 '14 04:03 hostilefork

So, you're proposing that execution be rebol> or >>, but botcommands be @rebolbot?

gchiu avatar Mar 19 '14 04:03 gchiu

JavaScript room has their bot respond to !!command and we could do that, so that !!avatar http://example.com/foo.png would work as a shorthand.

However, I think that the english-like @RebolBot blah blah helps emphasize the conversational nature of dialecting; makes it look less cryptic. But for evaluations, I think they're done often enough that a readable shorthand is better.

So my vote would be the language> syntax only applying to evaluations, keeping DO in the RebolBot dialect, and having all other commands still done by direct address as today.

hostilefork avatar Mar 19 '14 05:03 hostilefork

https://github.com/gchiu/rebolbot/blob/master/rebolbot.r3#L402

We can change the parse rule from

lib/botname some space

to

opt some space [ lib/botname some space | ">>" ]

which will catch leading spaces, and allow ">>" as a shorthand to address rebolbot. See if we can get this going first before attempting the other stuff. Redbot had better not do this though!

gchiu avatar Mar 21 '14 23:03 gchiu

I haven't checked to see what's happened to ideone but I'd imagine we can change the above rule to

| ">>" ]

to

| ">>" | "ruby>" | "java>" | "forth>" | ... where we set a flag in the rule as to which language we are going to use

gchiu avatar Mar 21 '14 23:03 gchiu

;; this rule is used for parsing out messages to the bot. Multiline messages have already had their
removed if it's @botname.
;; NB: untested!

bot-cmd-rule: [ opt some space [ lib/botname some space (copy key to end) | ">>" ( copy key to end replace/all key <br> " " trim/head/tail key insert head key "do " ) ](process-dialect key) ]

gchiu avatar Mar 22 '14 04:03 gchiu

I think we are commenting against the wrong issue, but I'll add in my comments here just to keep the flow :)

I was playing with this for the bot-cmd-rule:

bot-cmd-rule: [
    [
        lib/botname some space
        copy key to end |
        ">> " copy key to end ( insert head key "do " ) |
        "rebol3> " copy key to end ( insert head key "do " ) |
        "rebol2> " copy key to end ( insert head key "do/2 " )
    ]
    ; process-key-search trim key
    (process-dialect key)
]

then changing the parse in the main message loop as follows:

            parse content [
                [ <div class='full'> | <pre class='full'> ]
                opt some space
                copy content to [ "</div>" | "</pre>" ]
                (
                    if parse content [lib/botname #" " <br> to end] [
                        ; treat a newline after botname as a do-rule
                        replace content <br> "do "
                    ]
                    replace/all content <br> " " trim content
                )
            ]

Seems to work well, but I want to do a bit more testing first

johnk- avatar Mar 22 '14 13:03 johnk-

This parse rule requires a space after the prompt

Sent from my iPod

On 23/03/2014, at 2:09 AM, johnk- [email protected] wrote:

I think we are commenting against the wrong issue, but I'll add in my comments here just to keep the flow :)

I was playing with this for the bot-cmd-rule:

bot-cmd-rule: [ [ lib/botname some space copy key to end | ">> " copy key to end ( insert head key "do " ) | "rebol3> " copy key to end ( insert head key "do " ) | "rebol2> " copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ] then changing the parse in the main message loop as follows:

        parse content [
            [ <div class='full'> | <pre class='full'> ]
            opt some space
            copy content to [ "</div>" | "</pre>" ]
            (
                if parse content [lib/botname #" " <br> to end] [
                    ; treat a newline after botname as a do-rule
                    replace content <br> "do "
                ]
                replace/all content <br> " " trim content
            )
        ]

Seems to work well, but I want to do a bit more testing first

— Reply to this email directly or view it on GitHub.

gchiu avatar Mar 22 '14 17:03 gchiu

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

hostilefork avatar Mar 22 '14 21:03 hostilefork

Well we can always make it optional as well so that those who want it can use it. Otherwise just one more rule to explain to people.

Sent from my iPod

On 23/03/2014, at 10:23 AM, Brian Dickens [email protected] wrote:

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

— Reply to this email directly or view it on GitHub.

gchiu avatar Mar 22 '14 21:03 gchiu

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" opt some space copy key to end ( insert head key "do " ) | "rebol2> " copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

another variant on this rule

On Sun, Mar 23, 2014 at 10:26 AM, Graham Chiu [email protected] wrote:

Well we can always make it optional as well so that those who want it can use it. Otherwise just one more rule to explain to people.

Sent from my iPod

On 23/03/2014, at 10:23 AM, Brian Dickens [email protected] wrote:

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

Reply to this email directly or view it on GitHubhttps://github.com/gchiu/rebolbot/issues/46#issuecomment-38364566 .

Graham Chiu

gchiu avatar Mar 22 '14 23:03 gchiu

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

Sorry, want to make space optional after rebol2> as well

On Sun, Mar 23, 2014 at 12:54 PM, Graham Chiu [email protected] wrote:

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" opt some space copy key to end ( insert head key "do " ) | "rebol2> " copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

another variant on this rule

On Sun, Mar 23, 2014 at 10:26 AM, Graham Chiu [email protected]:

Well we can always make it optional as well so that those who want it can use it. Otherwise just one more rule to explain to people.

Sent from my iPod

On 23/03/2014, at 10:23 AM, Brian Dickens [email protected] wrote:

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

Reply to this email directly or view it on GitHubhttps://github.com/gchiu/rebolbot/issues/46#issuecomment-38364566 .

Graham Chiu

Graham Chiu

gchiu avatar Mar 23 '14 00:03 gchiu

the current bot-cmd-rule assumes that multiline commands do not occur after a >> or rebol3> or @rebolbot do

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) | ] replace/all key
" " trim key (process-dialect key) ]

On Sun, Mar 23, 2014 at 1:01 PM, Graham Chiu [email protected] wrote:

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

Sorry, want to make space optional after rebol2> as well

On Sun, Mar 23, 2014 at 12:54 PM, Graham Chiu [email protected]:

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" opt some space copy key to end ( insert head key "do " ) | "rebol2> " copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

another variant on this rule

On Sun, Mar 23, 2014 at 10:26 AM, Graham Chiu [email protected]:

Well we can always make it optional as well so that those who want it can use it. Otherwise just one more rule to explain to people.

Sent from my iPod

On 23/03/2014, at 10:23 AM, Brian Dickens [email protected] wrote:

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

Reply to this email directly or view it on GitHubhttps://github.com/gchiu/rebolbot/issues/46#issuecomment-38364566 .

Graham Chiu

Graham Chiu

Graham Chiu

gchiu avatar Mar 23 '14 00:03 gchiu

Working version currently being used by bot

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) ](replace/all key
" " trim key process-dialect key) ]

Now it can be changed so that

| |

and perhaps other stuff if we want to accept unescaped ruby

On Sun, Mar 23, 2014 at 1:22 PM, Graham Chiu [email protected] wrote:

the current bot-cmd-rule assumes that multiline commands do not occur after a >> or rebol3> or @rebolbot do

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) | ] replace/all key
" " trim key (process-dialect key) ]

On Sun, Mar 23, 2014 at 1:01 PM, Graham Chiu [email protected] wrote:

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" any space copy key to end ( insert head key "do " ) | "rebol2>" any space copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

Sorry, want to make space optional after rebol2> as well

On Sun, Mar 23, 2014 at 12:54 PM, Graham Chiu [email protected]:

bot-cmd-rule: [ [ lib/botname some space copy key to end | [ ">" | "rebol3" ] ">" opt some space copy key to end ( insert head key "do " ) | "rebol2> " copy key to end ( insert head key "do/2 " ) | ] ; process-key-search trim key (process-dialect key) ]

another variant on this rule

On Sun, Mar 23, 2014 at 10:26 AM, Graham Chiu [email protected]:

Well we can always make it optional as well so that those who want it can use it. Otherwise just one more rule to explain to people.

Sent from my iPod

On 23/03/2014, at 10:23 AM, Brian Dickens [email protected] wrote:

Requiring a space is okay by me, more legible (and it's the Rebol/Red norm anyway)

Reply to this email directly or view it on GitHubhttps://github.com/gchiu/rebolbot/issues/46#issuecomment-38364566 .

Graham Chiu

Graham Chiu

Graham Chiu

Graham Chiu

gchiu avatar Mar 23 '14 02:03 gchiu

In terms of the avatar command it sounds like a good idea. I am unsure if we need to authenticate any differently when moving between chat.* and the main SO site. Checked against the API v2.2 and there is no method to change avatar so we will have to reverse engineer it.

johnk- avatar Mar 26 '14 12:03 johnk-