-
-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the username of who is interacting with the bot, Plus one more issue #64
Comments
@AtbTheGreat I didn't find a way to do this without making an API call to Slack. My code is: public JSONObject getSlackUsername(Event event) {
String slackUserGetUri = "users.info?token=YOUR_TOKEN&user=";
Response slackUserResponse = slackRestClient.get(slackUserGetUri + event.getUserId());
return slackUserResponse.asJSON();
} I know this is less than optimal, but it gets the job done. |
Did you figure out the send a Direct message piece for this? I am needing to send a DM to users. |
@mndominguez can you elaborate on that example? these other methods aren't available in the example or the api. Where can I form a slackRestClient? |
Hey @adamoutler In my case, that private final NioRestClient slackRestClient = (NioRestClient) RestClientBuilder.builder()
.setNio(true)
.setBaseUrl("https://slack.com/api/")
.setSocketTimeout(2000)
.setMaxConnections(30)
.setMaxConnectionPerRoute(100)
.setConnectionTimeout(2000)
.build(); But any Rest Client implementation will be fine. OkHttp is a good choice. I'm unable to share the full code since it's for internal use at my company, but if you have any other questions just let me know. |
Thank you. I was banging my head on this for the weekend. I will share my
code when finished. I have no problem since it is open and for a gamer
team.
…On Tue, Jul 17, 2018, 11:11 mndominguez ***@***.***> wrote:
Hey @adamoutler <https://github.com/adamoutler>
In my case, that slackRestClient gets initialized like this
private final NioRestClient slackRestClient = (NioRestClient) RestClientBuilder.builder()
.setNio(true)
.setBaseUrl("https://slack.com/api/")
.setSocketTimeout(2000)
.setMaxConnections(30)
.setMaxConnectionPerRoute(100)
.setConnectionTimeout(2000)
.build();
But any Rest Client implementation will be fine. OkHttp is a good choice.
I'm unable to share the full code since it's for internal use at my
company, but if you have any other questions just let me know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#64 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAgOL1_ZaDahDPFo7u6m4-WtXoEdtCwoks5uHf6NgaJpZM4OezNI>
.
|
OK. Here's my solution. No additional dependencies were needed. Add Method to me.ramswaroop.jbot.core.slack.SlackApiEndpoints
Add Class UserResponse.java, anywhere.
Create a method
and access that with
|
|
I don't mean to bother you with so many issues, but I still need help on some aspects of the bot I'm working on, because I am almost done with my bot that uses the JBot framework except for a few aspects.
How do I get the username of the user currently interacting with the bot, as a String?
What
EventType
should I set the parameterevents
equal to so that my bot will automatically post a DM to each user at a certain time every day, even if no one is logged in? BTW, I am aware of how to useTimerTask
to set a certain time for the bot to send a message, but I need to know what to setevents
to.The text was updated successfully, but these errors were encountered: