Constraints of the problem:
My python bot needs to iterate through a list of messages to find reactions (I have that implemented and working), so I cannot use "on_reaction" or async's related to reactions on the final implementation
I don't want to use custom classes (I don't know how to convert my current code to be compatible and don't want to bother). I believe that means payload is out of the question?
What I have done:
I began with this tutorial: https://www.youtube.com/watch?v=iRHBGZWOwVo&list=PL6gx4Cwl9DGAHdJdtEl0-XiRfPRAvpbSz&index=6
I will summarize the relevant parts of the video, so you don't have to watch. I wrote code that uses aynscs to print the reaction emojis to the shell. I then copied and pasted the images into a comment in my code, and from there into the code where relevant. This worked great for 6 of the 8 emojis I am interested in detecting.
Detecting looks like such (for the working 6 of 8)
if str(reaction.emoji) == '💘':
The problem:
I used the same technique for all 8 emojis, but my bot isn't detecting two different ones, despite them being present in the search messages. These two emojis are :heart: and :hearts: by Discord's syntax. How can I get these emojis to be detected? I've tried every combination of reaction.emojis.name and str(reaction.emojis.name) imaginable.
I found this - and used the "copy" function and pasted it into the code. Worked like a charm. The discord :hearts: is just the Heart Suit emoji.
https://emojipedia.org/red-heart/
Related
I am learning how to develop Skills with Alexa. I followed a Lynda course to build the My Calculator skill, however ran into a problem where the numbers and results are not returned. I double checked my code, and tried it on Echoism.io, and same problem.
Per the attached, the numbers are recorded in the JSON input, however are not returned in the speechText or displayText?
What is the missing piece of code? Thanks.
Node.js code
Alexa console JSON Input
Welcome Roy! Couple things. In the future just put your code right here on the page so that it becomes searchable and we can see the exact characters you are using.
By looking at the images it looks like to me the following might be your use of template literals. Super common mistake.
So to use template literals you need use the back tick (`) instead of the single quote (')
It looks like it is that you currently have
speechText = 'The result of ${firstNumber} plus ${secondNumber} is ${result}';
and what you want is
speechText = `The result of ${firstNumber} plus ${secondNumber} is ${result}`;
Here is another good resources:
How to interpolate variables in strings in JavaScript, without concatenation?
There's a coding language called SugarCube designed for use in the Twine engine, which is used for text adventure games. Here's the Documentation for it. I'm not exactly an experienced coder - all I have is a few months in C# making a game in Unity - but I'd like to help a friend with his game, and hopefully writing his code in an editor instead of plaintext will help.
The only kind of code that matters is all marked with double angle brackets. Variables are marked with dollar signs $exampleVarand are declared and assigned using
<<set $exampleVar = "foo">>.
If and switch statements use closing tags similar to HTML:
<<if $exampleVar == "foo">>
// code
<</if>>
or
<<switch $exampleVar>>
<<case "foo">>
// code
<</switch>>
The guides I've found for custom syntax (including official documentation) are either outdated or assume you already know everything about YAML, which I don't. Advice?
I am making a pizza delivery chatbot and one of the training samples is
Are you open right now?
PARAMETER NAME ENTITY RESOLVED VALUE
time #sys.time now
One of the responses I want to have is if the time is between 12 am and 6 am , the reponse I coded is :
{{#if $time> 12:00:00}}I think it is too late{/if}}
But the response i am getting is :
{#if 12:00:34> 12:10:00}I think it is too late{/if}, which is wrong. Can someone help me on how to resolve this.
TIA
The Response section has a very very simple templating system - it allows for parameter/value replacement, and that is about it.
So you can specify a parameter value from an input phrase using something like $parameter-name, while parameter values in a Context or Event would be #context-name.parmaeter-name. You don't need the {braces} to do the evaluation, since those are used to escape the $ and # as special characters. So if you needed to show "$100", you would write that as ${100}. If you need the braces to be displayed, you'd include those inside another set of braces, which is why your text seems to get the braces removed.
You will need to put this processing in your fulfillment code. Libraries such as multivocal will let you create responses and setup response logic using templates. (Multivocal uses the handlebars templating library, for example.)
Good day,
I missed something in telethondocumentation. All is clear with files, messages, document, but i cannot find, how to send emoji to other user. When I send emoji code like ;-) it sends it as raw message. If it is equals to send file, please help me to find list of emoji id to put into file variable. Official documentation provides functions below, it is not clear.
GetEmojiKeywordsDifferenceRequest
GetEmojiKeywordsLanguagesRequest
GetEmojiKeywordsRequest
GetEmojiURLRequest
Please hint me with it :)
Emoji are just strings, like any other in Python. The ";-)" replacement for "😉" in official clients is done on the client side, not the server.
You should be able to paste the emoji directly into your code, or if your editor does not support it, use a Python unicode escape:
client.send_message(chat, '😉')
client.send_message(chat, '\U0001F609')
If you prefer to use text replacements in your code, install the emoji package:
import emoji
client.send_message(chat, emoji.emojize(':wink:'))
(Please note I have not tried the emoji module myself, see their documentation for available replacements.)
First of all: I don't mean parsing arguments and options from the process.argv array, but prompting the user and handling input/output. I've looked through the Node.js official module list without finding any sections or subsections that mentions input. In fact a search for 'input' on that page only gets 1 result which has something to do with YAML.
Anyway, I suppose cli input should be asynchronous and I've solved this issue before using stdin.on('data') which was messy to say the least. This seems like a perfect task for a node module which could come with extra goodies such as progress bars, spinners, coloured output, input validation etc.
There probably are some modules out there that does this, but I can't find any of them.
Help!!
(To clarify, the only functionality I require is the simplification of handling user input)
Search for modules here: http://eirikb.github.com/nipster/
Prompt: https://github.com/jesusabdullah/node-prompt
Progress bar: https://github.com/substack/node-multimeter
Colors: https://github.com/Marak/colors.js
Input validation: https://github.com/chriso/node-validator
More input validation (webbish tho): https://github.com/caolan/forms
Also, if you want to write your own: http://nodejs.org/docs/latest/api/all.html#readline
#node.js IRC welcomes you: http://webchat.freenode.net/?channels=node.js