Relay chatbot support / CLI integration for new chat.

heeheehee

Developer
Staff member
I posted this script in the public part of CG's forums: http://www.crimbogrotto.com/viewtopic.php?f=19&t=302

Anyone who uses KoLproxy and is in one of the clans with a Proxy-supported chatbot (mostly AFH and friends, I think) knows what the former bit does.

The latter is, uhm, a neat toy that piggybacks off of the old chat/CLI integration. I bundled it with this script because I already had an mchat.ash override.

edit: it's also on SVN.
Code:
    svn checkout svn://svn.code.sf.net/p/mchatoverrides/code
 
Last edited:

lostcalpolydude

Developer
Staff member
Excellent, I kept hoping something like this would show up, but for some reason never posted anywhere asking for it. At some point perhaps I'll be able to sort out what all of the javascript does. I changed line 68 of relaychat.js to
Code:
	      if (match = /^[\[\(\{]([\w ]+)[\]\)\}] (.*)$/.exec(msgs[i].msg)) {
to handle AFH bots fully, since the punctuation around a name depends on which clan they are chatting from.
 

heeheehee

Developer
Staff member
Oh no, you managed to capture the one line that I intentionally wrote terribly (regex coupled with side effect of assignment)!

Basically, how the relay chatbot part works is that it overrides jQuery's .ajax method to intercept the response from submitnewchat and mangle the message to change the sender and the original message. Pretty sketchy business, to be honest.

The CLI part piggybacks off of the old integration, except I like to think it's nicer because it's actually mostly integrated with chat, and it really wasn't that much effort to write, once I figured out how that whole interface worked. Maybe I should strip /cli off of chat commands passed to that tab, so /go and friends work.

I also accidentally left a console.log in there. Oops.
 

lostcalpolydude

Developer
Staff member
I just discovered that /me statements aren't converted. Pretty minor really, and I can probably figure that out once I have sufficient time and motivation.
 

heeheehee

Developer
Staff member
Yeah, I thought about adding that. It's currently impossible to detect /me statements in Mafia chatbotScripts (how the relay chatbots I've seen are implemented), so I'd never seen it myself.
 

heeheehee

Developer
Staff member
And... fixed / reuploaded. Added your change for other AFH bots, as well.

(will this regex ever stop becoming more complicated?)
Code:
/^((?:<i>.*?<\/a>)?) [\{\(\[]([\w ]+)[\}\)\]] (.*)$/
 

lostcalpolydude

Developer
Staff member
As the first line of get_player_id I added name = name.toLowerCase(); because yojimbos_law will result in 2048 /whois checks otherwise.
 
Last edited:

bugmenot2

New member
is there a way this would prevent the auto-away feature of KoL chat, like posting sth automatically every now and then, or run a silent command ... ?! Or is sth like this not even possible anyway?!
 

lostcalpolydude

Developer
Staff member
is there a way this would prevent the auto-away feature of KoL chat, like posting sth automatically every now and then, or run a silent command ... ?! Or is sth like this not even possible anyway?!

I expect that it is possible, but I don't think it's desirable, when you consider that it creates extra load on KoL's servers in a way that Jick/CDMoyer have specifically worked to prevent.
 

bugmenot2

New member
I expect that it is possible, but I don't think it's desirable, when you consider that it creates extra load on KoL's servers in a way that Jick/CDMoyer have specifically worked to prevent.
okay, that's a point.
but (it's getting really off topic now, sorry) do you know if I still get all the messages in chat, just slower, when away?!
(that's why I'm looking for this feature. Because currently I just go there every 10 minutes to type /friends ..... oh well....)
 

T_E

Member
(I posted this in the CG thread as well- posting here to cover both bases)

Hello~ revision 29 seems to have messed up AFH/k bot support as well as the CLI feature.
Is there a way to revert to an older version of the script, if this isn't going to be fixed?
Thanks in advance (and thank you for this script). =)
 

Theraze

Active member
If you ever want to revert to an older version, just use svn dec <script name> and it will decrement you to an earlier version. Then just don't svn update it.
 

lolli

New member
heeheehee -

I noticed that with your latest update I had to wait for about an hours worth of chat when I had to restart my browser. Is this intended behavior, it took a long time.

Thanks
 
Top