How to match bold inputs in hubot coffeescript - coffeescript

I am working to develop a hubot slack application where we can give commands from the slack chatbot and give the response back using coffeescript.
now, I am able to use the slack bot with this.In cofeescript i have ,
module.exports = (robot) ->
robot.respond /hi/i, (msg) ->
console.log(msg.message.text)
sender = msg.message.user.name.toLowerCase()
msg.send "Hello small " + sender
msg.finish()
here if i give
hi
in slack bot, i receive
Hello small indhumathi
and when i try to give the same in bold "hi" it is not responding since the bold characters are not matched in the coffeescript to process.
So my requirement is to change the code which should accept both bold and unbold texts. Please help me in this. I am new to coffeescript.

Related

Apps Script is adding line breaks to email bodies

I am generating emails with Google Apps Script and the emails are being sent with line breaks in weird places.
Here is my code
function sendEmail(){
var name = "MyName"
var body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." +
"\n\nNOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
GmailApp.sendEmail("MyEmail#gmail.com", "You've been challenged!", body)
}
You'll notice that it is also putting the text of the first section of the body in a purple color. I also don't know why this is happening but my priority is to stop the line breaks from being put where they shouldn't be.
Google 'Stacks' emails. Say for example I send you an email. Then you reply and I reply again. It stacks them all into one line in your inbox.
Any identical paragraphs in the emails are made purple. Only you see the purple.
If you delete all of the emails out of your inbox and test again, you should notice it in black.
Also, you have code to create two new lines. '\n' x2. You're essentially creating a new paragraph, do you just want a new line to begin instead? If so delete 1x '\n'. Sorry if I'm not understanding your issue.
If you were to insert the body as html and use paragraph tags you would likely be able to achieve the results you are pursuing.
I am on mobile and don't know how to get resource links to prove the above sorry.
Edit: I would make the following change:
body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." + "\n\n" + "NOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
Your code is including the body as plain text so it is automatically cropped at certain line length. Below some questions about the same "problem"
Gmail API - plaintext word wrapping
Why isn't Gmail using quoted-printable encoding?
If you want to have more control about how the message content looks on Gmail, besides sending the content as plain text sent it as HTML. For doing this use
sendemail(recipient,subject,body,options)
Related questions about using the above method:
Sending an email in HTML and plain with a Gmail Apps Script

Hubot Slack: How to send message includes channel link?

I wrote following hubot script to send remind.
OUT_CHANNEL = "remind"
module.exports = (robot) ->
robot.hear /test/, (res) ->
res.send "set reminder. I tell you at ##{OUT_CHANNEL} after this."
...
This script sends below messages.
"set reminder. I tell you at #remind after this."
But This case, the part of #remind is not link.
how to embed channel link in hubot message like human send?
Environment is below:
hubot 2.19.0
hubot-slack 3.4.2
slack-client 1.4.0
Slack.app 2.5.2
If you want Slack to show a link to a channel the correct syntax is:
<#C12345678[|text]>
Where #C12345678 is the ID of the public channel, and text can be any text (and is optional). So <#C12345678> will work too.
I am not familiar with the coffeesecript syntax, so please add any script related character encoded (e.g. ## for #) as necessary.
Please note that this will only work for public channel, but not for private Slack channel.
You can read more about how to correctly link items in Slack messages in the excellent Slack API documentationn.

Auto generate a partly trimmed email

I'm developing a message client and I need to auto generate an email on the server and send it to the user each time a new message gets posted in the message client. The email should have the latest message in the top and the rest of the conversation in trimmed form after the latest message.
In Gmail it's displayed as an ellipsis icon [...] that expands on click. Is there some kind of "standard" amongst email clients how to achieve this and what characters or html do I need to include in the email body?
I've tried things like below, but can't get it to work.
Latest message
>> Earlier message 1
>>
>> Earlier message 2
>>
>> etc...
What are we talking about here? HTML? You could use something like jQuery and replace the div each time it is clicked.
$( "#earlierMessage1" ).click(function() {
$('#earlierMessage1').html(earlierMessage1Contents);
});
A lot more info needed either way I'm afraid.

Sharepoint: use mailto command to send subject and body

I am developing in SharePoint and I would like to prepare a mailto command but I would like to send two values to the email and not just one. Normally in html the command works
Email
But in SharePoint I seem to only be able to send the first section after the email#here.com?. Depending on what I position first, I sometimes get the #Body field to go through or the #Title to go through. It appears that for some reason the "&" isn't accepted. I also tried %26 in the place of & with no result.
What is the best method to get both (body and subject) to go through to the mail-client?
Thank you in advance for your time, any guidance will be greatly appeciated

Win8/WinRT - How to add line breaks in email body

In my Windows 8 Store app, I have a Send Email button on a page and users are able to click it and send us an email for some general enquiries.
I need to pre-load some text in the email body but I can't seem to add line breaks to it. I tried Environment.NewLine and "\r\n". None of them works.
var mailto = new Uri("mailto:?to=james.jones#example.com&subject=Hello world&body=Hi," + Environment.NewLine + "Can you please ...");
await Windows.System.Launcher.LaunchUriAsync(mailto);
When I run it, I get "Hi,Can you please...". The line break is omitted.
Try using "%0d%0a" as your line break, as in
"Hi,%0d%0aCan you please..."
That's a URL-encoded ASCII CR/LF sequence. That works for me for the built-in Mail app but you don't have any particular guarantee that it would work for any arbitrary mail app that the user might install in the future.
The reason it doesn't work is because you're launching a Uri, Uris require that their contents be UrlEncoded / UrlEncodable. In the case of Environment.Newline etc you'd get an invalid Uri.
You can counter this by UrlEncoding the Environment Newline like this:
System.Net.WebUtility.UrlEncode(Environment.NewLine)
You maybe should consider using a Share Contract to share your content to your Mail App. Benefits: Users using your software can share it to other Apps, not only Email.