-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention api add @ automatically no matter it is already exists in the text #1718
Comments
I would suggest two ways of solving this
Personally I would prefer the second one, since the first one is not stable, it requires the name has to be exactly the same with the one in wechaty, and if there are |
@huan Let me know which one you prefer, I would like to PR for this issue. |
I have one question for this issue: what's your purpose for doing the following task?
I do not think I'll do this. Instead what I'll do is:
Please help me understand your situation and I'd like to help you to get a fix for this issue. |
We are trying to put the
So basically this is not possible currently with the existing |
That makes sense. I'll think about your purpose and come back to you later. |
Thanks very much @huan , u r the best. |
kindly ping @huan |
I'm afraid that I would not like to add another parameter for specifying whether to include the mentioned contact name in the message because that will make things complicated. How do you think the following syntax? We can use the ES6 templated strings which support Tagged Templates: room.say`Hi ${contactA}, here is ${contactB}.` You can learn more about the Tagged Templates for ES6 at here |
I understand that you want to make apis simple, but since the function getting more and more complex objectively, I don't think there is a way to keep the function simple and easy to use at the same time. If we add another parameter to the func, we can easily explained to them and the only thing they need to know is the difference between auto generate And from implementation perspective, what I am doing is setting up a webpage that control the bot to say something, so the data or command send to the bot is over the http, I can not pass |
|
But the text in With the |
No, it's not. You need to understand the Tagged Templates first, please see the links that I provided to you in the earlier reply. After you do understand what the Tagged Templates are, then we will be able to continue discussing how to implement your new feature request. |
I understand what the Tagged Templates are, could you please provide a demo code showing how that works with the mention function? |
I don't think you had understood, because I had already demonstrated it very clearly in the previous post: room.say`Hi ${contactA}, here is ${contactB}.` That's it! :) |
Could you explain to me how to make the text to be a variable and pass it from somewhere else into the say function? Say I have a service A want to tell my bot to say function sayAsTold (messageNeedsToBeSent) { // What type should the parameter be?
const room = await bot.Room.find({name: 'someName'})
room.say() // ??? What to do here
} |
function sayAsTold (contactA, contactB) { // What type should the parameter be?
const room = await bot.Room.find({name: 'someName'})
room.say`Hi ${contactA}, here is ${contactB}.`
} Please read the link that I provided in the previous reply carefully, and make sure you had understood it well. |
I don't want the text to be fixed inside the function, I might have multiple sentence to say, like So that means the template has to be a variable, could you please show me how to do that? I DO understand what is So I am trying to think in your way, then I might need one more parameter in my function, which is the template. Could you please tell me what the template should be looks like? And how to call the const template = `` // ??? what should be here
function sayAsTold (contactA, contactB, template) {
const room = await bot.Room.find({name: 'someName'})
room.say`Hi ${contactA}, here is ${contactB}.` // How to leverage the template and also contactA and contactB
} |
Tagged template imposed a big stress in the developer side, and forces them to stick with JS for their development. I feel that we could do the same thing by passing in room.say(`Hi, contact@12312312, here is contact@234234234`) |
@lhr0909 Yes, your suggestion is the point what we should consider about. However, can you share some opinion from your knowledge on the Tag Template first? Because it seems that you are familiar on that. After we made the Tag Template clear enough, then we will be able to talk future about how to make developer from other languages happy. |
@huan We are trying to build a chat box for our user to talk with their friends, we want to give our user the ability to mention someone in the room, so our user will input a text, in a human readable way, then we process the text, pass to wechaty and send out in wechat. If we embedded the contact id or something into the text, then we need to maintain two versions of text at the same time, one is a readable one for our user, the other one is the one to send to wechaty, that increases our complexity of the system. Thus, I don't like the idea to embedded contact information into the text string. I know we have different scenario from the chatbot one, but still, we are developers develop apps with wechaty. From my perspective, simply add another parameter makes our development easier. |
@windmemory Slorry I could not be able to understand your needs according the information you provided in the last replies. Will go back to read them again when I have time. |
@huan Yeah, I think I did a bad job on expressing my situation clearly in my previous comments. Thanks for your understanding, and let's make something that well considered and friendly to use. |
@windmemory Had this issue been resolved? I remember some PR related to this problem had been merged. Please refer to the PR in this issue and close it if it had been implemented by the PR because we should only leave the unresolved issues open. |
I think we can close this issue. This is resolved. And the related PR is located above. So no need to link any PR to this. |
Thank you very much for keeping the house clean! |
0. Report Issue Guide
Please search in FAQ List first, and make sure your problem has not been solved before.
Please search in the issue first, and make sure your problem had not been reported before
1. Versions
What is your wechaty version?
Answer: 0.23.40
Which puppet are you using for wechaty? (padchat/puppeteer/padpro/...)
Answer: padpro
What is your wechaty-puppet-XXX(padchat/puppeteer/) version?
Answer: 0.0.51
What is your node version? (run
node --version
)Answer: 0.15
What os are you using
Answer: Mac
2. Describe the bug
When calling
room.say()
with an mention contact passed in, it will always add a@XXX
at the beginning of the text3. To Reproduce
This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.
Reproduce code
4. Expected behavior
Only one @ sign in the text, like
你好啊@高原
, instead of@高原 你好啊@高原
.5. Actual behavior
Two @ sign appear in the text.
6. Full Output Logs
Set env
WECHATY_LOG=silly
in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)The log is not necessary.
7. Additional context
Add any other context about the problem here.
code in wechaty
The text was updated successfully, but these errors were encountered: