A question about discord embed descriptions (i am using Java discord library) - discord-jda

I want to make multiple spaces in discord embed descriptions, here is my code:
embedBuilder.setColor(Color.darkGray);
embedBuilder.setDescription("blah blah");
event.getChannel().sendMessage(embedBuilder.build()).queue();
But when I look at the output in the discord server. It says:
blah blah
But what I really want is a: blah (multiple spaces) blah

try using \t instead of the many spaces. It would look like this:
embedBuilder.setColor(Color.darkGray);
embedBuilder.setDescription("blah\tblah");
event.getChannel().sendMessage(embedBuilder.build()).queue();
I also have a website for you that simplifies working with embeds:
Discohook | Embed Generator

Related

Is there a way to stylize responses from AWS Lex

I'm using Lambda and Lex to return responses to end users, however I'm wondering if there is a way to bold or italicize certain words in a response. I know it would be parsed by the platform running Lex which is fine.
It is possible, but it depends on your output channel.
For example if you are using Facebook Messenger, then try:
BOLD = surround with asterisks * ... *
ITALICS = surround with underscores _ ... _
Strikethrough = surround with dashes - ... -
(just tested and works in desktop messenger, but didn't work in mobile messenger app)
So check the output channel requirements for style options, and then just be careful with how it is passed as correct JSON and parsed through Lex.

How do I create a multiline bot response in Rasa Core?

Can anyone help how to get bot responses in multiple lines.
Also how to get bullets in the Bot responses. I tried with >, * , enter key and also. Nothing seem to work. Does Rasa response templates support HTML tags?
The visualization of the message depends on the output channel which you are using.
Hence, it should be possible to provide HTML tags in your bots answers as long as your output channel can then correctly render it. For a simple newline, please try adding a "\n" in your messages, e.g.:
utter_message:
- text: "First line\nSecond line\Third line"
You can also have a multiline string in your yaml file which then results in a string containing newlines (see here for examples). The block below is the same as the example above:
utter_message:
- text: >
First line
Second line
Third line
To include bullets, you could simply add the unicode character of a bullet, e.g.:
utter_message:
- text: >
• First line
• Second line
• Third line
I think newlines doesn't correspond to "multiple bot responses" (that I interpret with multiple boxes on a instant messaging/caht channel. It's so in Telegram, by example. So I fair #Tobias solution isn't definitive.
A solution to have separate box messages could be to split the original single utterance in a sequence of utterances to be inserted afterward in a "story" as described in this RASA forum reply: https://forum.rasa.com/t/split-utterances-templates-into-multiple-answers/1204/2?u=solyarisoftware
That's more a workaround but that's debatable from the conversational design perspective. Maybe I want different boxes not just for a text pretty printing with newlines, but to communicate different semantics.
For example, if the user say:
Hello
The bot could reply answering the greet and also introducing a new question/prompt to let the dialog continue.
And that could deserves a new box, for a sequence of 2 boxes.
So bot reply could better be:
Hello!
How are you?

Trying to find a regexp to use for Tumblr

I am trying to find a regexp that is capable of grabbing a full tumblr link in ruby.
I have been using this regexp for flickr, foursquare and a few other sites because it easily allows for me to grab all the text surrounding it.
/(?:https?://)?(?:www.)?flickr.com/\S+/g;
But Tumblr, given the name of the user/blog that precedes the .tumblr has me at a loss and obviously doesn't allow me to use this.
http://heywatchthismovie.tumblr.com/
Would love any advice on what to do.
Pattern match on \w+ to find the subdomain.
> s= 'blah blah http://heywatchthismovie.tumblr.com/ blah blah'
=> "blah blah http://heywatchthismovie.tumblr.com/ blah blah"
> s =~ %r{(?:https?://)?(?:\w+.)?tumblr.com/}
=> 10

How to syntax-highlight function arguments inside function in Sublime?

I would like to highlight the arguments of a Ruby function in Sublime, when they are used inside the function. Like so:
def my_func(arg1, arg2 = nil)
puts arg1 # should be highlighted
puts arg2 # should be highlighted
end
I've been messing with Sublime's plist syntax highlighting format for a while (same as Textmate's), but having trouble figuring out how to capture one group (the args in the def line) and use them to match more expressions in another group (the whole method)
I have seen \1 and \2 being used in EndCapture groups before, which gives me hope that this is possible, for example by using \1 in a match group. But I just can't seem to get it to work. Anybody have any ideas?
(too long for comment)
If writing regexes in XML/PLIST is driving you batty, try installing the PackageDev plugin via Package Control. There is an option to convert PLIST .tmLanguage syntax files to YAML, and when you're done editing you can convert it back to PLIST. This way, you don't have to mess around with trying to get all the <dict><array><whatever> tags correct in the .tmLanguage file, and you can focus on the regexes, capturing groups, etc. It also uses the Oniguruma syntax, which I assume you're at least somewhat familiar with if you're a Rubyist. I maintain an improved syntax for Python, and my work has been so much easier since I started using the .YAML-tmlanguage format.
Good luck!

Regex Markdown Header

I'm trying to create a regular (ruby) expression which checks for multiple conditions. I use this regex to replace the content of my object. My regex is close to finished, except two problems I'm facing with regard to markdown.
First of, headers are giving me trouble. For example, I don't want to replace the word "Hi" for "Hello" if "Hi" is in a header.
Hi John <== # should not change
==================
Text: Hi, how are you? <== # Should be: Hello, how are you? after substitution
Or:
#### Hi Peter <== # should not change
Text: Hi, how are you? <== # Should be: Hello, how are you? after substitution
Question: How can I escape markdown headers within my regex? I've tried negative lookbehind and lookahead assertions, but to no avail.
My second problem should be quite easy, but somehow I'm struggling. If words are Italic "hi" I want to find and replace them, without changing the underscores. I can find the word with this regex:
\b[_]*hi[_]*\b
Question 2: But if I would replace it, I would also change the underscores. Is there a way to only detect the word itself and replace it, while still using word boundaries?
Code Example
#website.autolinks.all.each do |autolink|
autolink.name #for example returns "Iphone5"
autolink.url #for example returns "http://www.apple.com"
regex = /\b(?<!##\s)(?<![\d.\[])([_]*)#{autolink.name}([_]*)(?![\d'"<\/a>])\b/
if #permalink.blog_entry.content.match(regex)
#permalink.blog_entry.content.gsub!(regex, "[#{autolink.name}](# {autolink.url})")
end
end
Example text
Iphone5
==============
Iphone5 is the best mobile phone there is, even though the people at Samsung probably think, or perhaps only hope that their Samsung Galaxy S3 is better.
#### Samsung Galaxy S3?
Yes, that's the name of the newest Samsung phone.
This will result in a text with HTML tags, but when I use my regex my content uses Markdown syntax (used before the markdown converter).
Regexes work best when they do one clear thing. If you have multiple conditions, your code should usually reflect that by dividing the processing into steps.
In this case, you have two clear steps:
Use a simple regex or other logic to skip over the header portion of the message.
Once you know you are in the content, use another regex to process the content.
I've found a solution:
regex = /(?<!##\s)(?<![\d.\[a-z])#{autolink.name}(?![\d'"a-z<\/a>])(?!.*\n(==|--))/i
if #permalink.blog_entry.content.match(regex)
#permalink.blog_entry.content.gsub!(regex, "[\\0](#{autolink.url})")
end

Resources