Detecting when a user leaves or enters a channel with hubot - coffeescript

I am trying to make Hubot detect when a user enters or leaves a channel, but so far I have been unable to actually find ANY information pertaining to this.
Does anyone have any ideas of how to do this? :)
Thanks in advance!

Hubot's Robot class has functions enter and leave that will fire a callback you give when any user enters or leaves the room. That callback takes a Response, which has a property message of type Message, which in turn has a property user of type User.
module.exports = (robot) ->
robot.enter (response) ->
# at this point you can get the user's name with:
# response.message.user.name
# works the same for robot.leave
However, it appears that the IRC adapter for hubot doesn't currently fire the messages needed to get those functions to work.

Related

Thunderbird78+: How to check for message create, reply and forward

I am a beginner in thunderbird addons so I really appreciate if you can help me. I am trying to find a way in my background javascript to check whenever a user has opened the window for create a new message, reply a message and forward a message. I want to put a default text in the message window before the user is gonna send it. I know thunderbird 78+ should only uses web extension APIs and i found this Compose API but how to use it in my background script.
https://thunderbird-webextensions.readthedocs.io/en/78/compose.html
It looks like setComposeDetails() is what you want.
setComposeDetails(tabId, details)
Updates the compose window. Specify only fields that you want to change. Currently only the to/cc/bcc/replyTo/followupTo/newsgroups fields and the subject are implemented.
tabId (integer)
details (ComposeDetails)
I have note tried it, but I suppose that either details.body or details.plainTextBody from the ComposeDetails object can be used to pass the default text you want to use. So I would try something like this in the background script:
let details = {
body: "This is my default text",
};
browser.messages.setComposeDetails(tabId, details);
You might have to combine it with a call to messages.getComposeDetails() if empty fields in details reset the values in the composer window (I don't know).
If you want to call this when the user opens a new compose window, I would look at the window.onCreated event. If you want to do it right before the message is sent instead, you should look at the compose.onBeforeSend event. All of them are described in the API documentation.

Send a code for password reset via email - Swift + Firebase

I am creating a simple Swift app. I have got the login working with Swift app. Now, when a user clicks on forgot-password, I want to send them an email with a code. Once he enters that code, he can enter a new password.
I looked up at Firebase.auth.auth() I saw functions like checkActionCode() and applyActionCode() - I couldnot understand a clear difference between them!
I also saw some other functions like confirmpasswordReset() and verifyPasswordResetCode().
However, I do not understand what function to use and how to send an email with the code. Can someone give me an overview of how can I do this? Thank you!
If the user forgot their password, you can send them a password reset email with:
Auth.auth().sendPasswordReset(withEmail: email) { (error) in
// ...
}
This email contains so-called OOB code and a link to an auto-generated page that allows them to reset their password. I recommend getting started with this approach, since you'll have to do the least work to get it up and running.
If you want to create your own page instead of the auto-generated one, have a look at the documentation on custom email action handlers. That page also contains an example showing how to call the handleResetPassword, handleRecoverEmail, and handleVerifyEmail methods.

Can’t Override Default Cancel Intent

Is there anyway that I can add a custom message when user says ‘Cancel’ or ‘Exit’ to end the conversation?
I have added intent for these utterances and connected it with my webhook but the message I send back in app.ask() is not displayed or read.
This is currently a known issue and you cannot override these words currently. You can handle handle other words like "quit", "finish", "exit", etc.
Done using API.AI. (see the picture)
http://i.imgur.com/WDQWmwb.png
As per this specification
Conversation Exit google assistant
probably you will only able to do an app.tell() in your webhoook because this must be a final Intent (you can tell something to user but not ask and waiting for a response), see point five of suggested configuration:
Enable Set this intent as end of conversation
In every case if you use a weebhhok take care: The maximum execution time allowed for conversation exit requests is 2 seconds

FB Chatbot how to get the previous message

Is it possible to receive the previous message that the user have send to the chatbot (without using quick replies or postback buttons). Example:
User: "Can you call a friend?"
Bot: "Who should I call?"
User: "Tim"
In the API I now have just the information "Tim", without knowing if I should call him or text him or make him a sandwich or whatever. So I basically I want to add some Postbackdata or metadata additionally to the text "Can you call a friend" (intent: 'CALL'), so the message "Tim" will come with that data.
Is there a way without storing the data into a database? AWS Lambda with ClaudiaJs.
I found the metadata field in the FB API which turns out to be the wrong field for that since it is only for communicating between several apps?!
What you are looking for a called a "slot-based bot", or slot-filling, basically meaning that you have a "slot", or blank that needs to be filled in before your bot can perform an action. In your example you have two slots: action and person
Actions could be: call, text, message
Person: name of a person, friend, etc.
I don't think any of the message frameworks (Slack, Facebook, etc) will provide you with the information you need. You will need to build this logic out yourself.
You can look at using wit.ai stories to achieve this.
Look to this similar Stack Overflow question and answer.
You can reverse order of conversation, and at beginning user writes some text or send you something else. After receiving, you should send to user buttonsTemplate, where postbacks will be like "CallTo&Tim" where instead of Tim you can put every text you need to pass to next executor(and you also can store previous user message here). Than just make substring of postback, check it`s type and do whatever you want.

Stop Hubot (with Flowdock) from responding to itself?

I'm using Hubot with the Hubot-Flowdock adapter.
I'm using robot.hear to respond to messages with a certain string in them (e.g. "chocolate").
I then call msg.send with a message, which also happens to contain the trigger string ("chocolate") in it.
This causes Hubot to hear itself, and then just loop endlessly, triggering over and over again.
I'm trying to find a way to get Hubot to not respond to itself.
From what I gather, the Hubot Campfire adapter seems to include a specific check to prevent Hubot from listening to itself:
https://github.com/github/hubot/blob/b96ea30654ef2dbf93f710c6e310c909fa1bdd65/src/adapters/campfire.coffee#L71
However, other adapters don't seem to have this.
Is there another way to write a Hubot script with robot.hear and msg.send such that it will not respond to itself?
I found the answer to this - Hubot is not meant to respond/hear itself.
It's the responsibility of each adapter to handle filtering these messages out.
Some adapter (e.g. hubot-hipchat) will actually set the hubot bot name to the name of the user you authenticate in Hubot as.
In the case of hubot-flowdock, it will check the hubot bot name against the Flowdock "Display name" of the user you authenticate as - so you just need to make sure those match up (either by changing the "Display name" on the Flowdock account page, or using the -n flag or HUBOT_NAME environment variable to set the bot name).