Open cereda opened 8 years ago
Hi Paulo,
If the format of the fkey
is the only difference, it sounds like supporting StackExchange would be relatively straightforward. Can you tell me how the fkey
looks for a StackExchange chat room?
Thank you, Mike
Hi Mike!
Sadly, I could not spend much time in the code, as I have a thesis to write (ouch). :wink: To the extent of my checking, the StackExchange fkey
seems to keep the usual 32 hexadecimal digits with the addition of four hyphens acting as separators. I suspect the regex could be expressed along the lines of value=\"([0-9a-f\-]{36})\"
(untested).
Still, the login part looks a bit tricky, as it is done via StackExchange OpenID (and the site sometimes redirects connections). I was looking at ChatExchange for some hints, and it seems the OpenID part requires some tweaking indeed. But, apart from this nuisance, the port looks potentially doable (I am trying to be cautious on saying strong statements :wink: ).
I offer my help to tackle the login part, although my time is quite restricted nowadays. And please, feel free to ignore this request if, at the end of the day, tweaking the code would cause a lot of headaches. :wink:
All the best!
Paulo
Thank you for the information, Paulo. It sounds like it's not as simple as originally thought. :( However, this would surely be a nice feature to add. Maybe I will work on it later. Good luck with your thesis!
Repoking this issue: I have added support for Stack Exchange in my bot (based on OakBot). Simply changing the domain is enough. There are however some pitfalls to be aware of:
Those should be fairly self-explanatory. Once you change the site, user ID's change. Room ID's too. Passing the domain allows you to get the appropriate property from bot.properties (for an instance so_admins and mse_admins. Check the domain, set admins to the right one). Passing domain to Rooms (class) you can append that to the name (for an instance stackoverflow.com-rooms, meta.stackoverflow.com-rooms) which saves the appropriate room IDs to the appropriate database entry.
I'm still working on implementing this, primarily connected with meta stackexchange but it appears to be universal. any *.stackexchange.com has chat at chat.stackexchange.com. Custom domains (stackoverflow.com, superuser.com, etc) have at their own domains. Checked the fkey regex, and looked for the fkey in Shadows Den (on meta stackexchange chat) and it matched. 32 hex.
As for login, changing the domain in StackOverflowWSEvents (added a second constructor, domain defaults to stackoverflow if not defined) and nothing else allows login.
It is primarily admin ID's, banned ID's and bot ID that causes issues. Still working on implementing fixes in my bot
Cool, thanks for the additional info. :)
Hi friends!
Sorry for the huge hiatus (note to self: PhD takes more time than expected). Any updates on this? I tried the code a couple of minutes ago and I failed to make it work on a StackExchange room. Perhaps @LunarWatcher could give me some hints. :wink:
All the best!
No, sorry. :( Haven't worked much on Stack Exchange compatibility. Also: ducks!
Hi Mike!
No worries, pal. :wink:
Quack! :wink:
Just as a heads-up, SE openID is deprecated, which can result in problems with login to SE later. SO login, as originally done in the bot, is fortunately not affected. But login into SE chat still uses OpenID. Meta.SE login is virtually the same as into SO, but SE is still complicated because it uses different endpoints.
First you POST to https://stackexchange.com/users/login#log-in
, and get a URL from the body. You use that URL to get the fkey, which you then POST along with username and password to https://openid.stackexchange.com/affiliate/form/login/submit
, in addition to affId
set to 11. Finally, using that response, you create a final response using a URL in some JS code called var target
. GET that, no arguments used here, and then check the response for the status on the login.
Hi @LunarWatcher! Thank you very much for the heads up, I will try to delve into the code. :wink:
Quack! :duck:
@LunarWatcher Do you have any code you could post for the SE login? Or know where I can find some? I spent about an hour trying to get something to work, with no luck.
The hard part is that the SE login page uses JavaScript to submit the credentials. The login URL that you posted wouldn't quite work with the bot at face value because the anchor ("#log-in") causes some JavaScript to run in the browser.
Never mind. I think I figured it out! I was trying to use Firefox's F12 developer menu, but it was clearing the list of network requests on every click, so I couldn't see the URLs the browser was sending requests to. Edge actually worked better. 😵
Ok, I think I got it working! Thanks for your tips @LunarWatcher!
Let me know how it works if you try it out! 🎉
Brilliant, friends! It's working like a charm! Time to revive our beloved Psmith! All the best!
Friends, sorry to bump this issue, but I do believe recent changes in SE broke the support. I will try to take a closer look during this week and report back...
Happy Easter! :wink:
Ugh, just great. 😕 Thanks for letting us know! 😀
Deeply sorry @mangstadt... :cry:
Hi there, congrats for the cool project! :wink:
Is there any plan for supporting StackExchange-based chatrooms? I did a couple of tests and it looks doable: although I could not make the bot successfully login, it intercepts messages and parses them accordingly, so it seems we are almost there. :wink:
Just a quick info: maybe the
fkey
regex should be redone as the format looks quite different in SE sites (as it incorporates arbitrary length and hyphens). An alternative solution is to rely on jsoup for getting data from HTML sources.Keep up the good work! :cake:
All the best,
Paulo