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).
Related
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.
I've been running the echo.html example that comes with Strophe.js. When I start it up I sign in using a user I made called user1. When I click the connect button I get the following output:
Strophe is connecting.
Strophe is connected.
ECHOBOT: Send a message to 5ee09j8v8y#ubuntu/5ee09j8v8y to talk to me.
I am able to successfully test this example using the Gajim client. In Gajim I simply start a new chat using the above JID (5ee09j8v8y#ubuntu/5ee09j8v8y). When I send a message using Gajim it shows up on the echobot example and everything is hunky dory.
So here's my question, I see from this official site that the JID is in this format:
<JID> ::= [<node>"#"]<domain>["/"<resource>]
And I get that the resource is optional, and that the domain in my case above is simply my computer's name (my computer's name is ubuntu). BUT what I don't get is how the heck you get 5ee09j8v8y from the username user1.
The code inside echobot.js which prints the JID line above uses this command to get the information:
connection.jid
Which is just a Strophe.Connection Object retrieving it's JID.
So to sum all of this up, I cannot communicate from Gajim using user1#ubuntu/5ee09j8v8y the only way it works is when I use the JID 5ee09j8v8y#ubuntu/5ee09j8v8y. So what exactly is the node (5ee09j8v8y), how does it get mapped to the username (user1), how can I get Gajim to work with user1#ubuntu/5ee09j8v8y instead of using 5ee09j8v8y#ubuntu/5ee09j8v8y and at the very least can someone point me in the right direction to some documentation on this JID problem?
Note: This tutorial will explain my setup (and help others who are curious in how I set all of this up).
I use AppleScript and can send messages without any problem, but the "Sent" box does not get a copy of what I sent. However, if I use Mail Application to send messages, the "Sent" box gets a copy of what I sent. So I guess my AppleScript may miss a command or so to tell Mail to keep a copy of the sent messages. What's the command that I missed? Thanks.
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return, visible:true}
tell theNewMessage
set visibile to false
set sender to theSender
make new to recipient at end of to recipients with properties {address:theAddress}
make new attachment with properties {file name:theAttachment} at after the last paragraph
send
delay 5
end tell
end tell
I don’t think you’re missing any command. I copied your script to Script Editor on my iMac, set values for theSubject, theBody, theAddress, theSender, and theAttachment, and ran it. It (a) successfully sent the message, and (b) I was able to view the message it sent in my Sent mailbox.
I tried this both with a known sender and with a random example.com sender. In both cases, it was saved in the default Sent box.
So the issue most likely lies elsewhere. Make sure that the value you’re currently using for theSender maps to an account in Mail that saves sent messages. (If it’s an IMAP account, it may be saving sent messages on the server, and server behavior may be affecting what you see.)
If that doesn’t work, set up some test values for all of the variables in the script except theAddress (using example.com for theSender), and include those (except theAddress) in your question. (If you can use example.com for theAddress, too, do that, but some servers will simply refuse the message immediately, which makes it worthless for testing this particular case.)
Note that you have an error that does not change this behavior; you have “visible” misspelled as “visibile”. However, I tried it both ways and in both cases the outgoing message does get stored in the appropriate Sent box.
Try adding this after you send the message...
set accountReference to first account whose name = "my account name"
synchronize with accountReference
I'm new to Fiddler and have run across something that seems strange to me. If I select an entry and then click Replay, I get different behavior from when I drag an entry into the Composer window and click Execute.
Should the different behavior between these two methods of re-making a request be different?
Note: I called the second method "cloning" a request because the Composer window says "You can clone a prior request by dragging and dropping a session from the Web Sessions list)."
What is the "different behavior" specifically?
The two operations you describe should behave the same way unless the server returns a redirect or an authentication challenge, in which case preferences will control whether Fiddler automatically authenticates and/or follows the redirect.
Please feel free to email me (Help > Send Feedback) details and/or screenshots of the difference you see.
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.