Skip to content
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

Infinite message loop =) #82

Open
stefan-reich opened this issue Jun 16, 2020 · 4 comments
Open

Infinite message loop =) #82

stefan-reich opened this issue Jun 16, 2020 · 4 comments

Comments

@stefan-reich
Copy link

Hi, I just set up skyweb for testing.

One small thing: I believe "cd dist/demo" should read "cd dist/src/demo" on https://www.npmjs.com/package/sky-web-plus.

Here's how it went though. I had to make an account without 2FA, then I could use it with the skyweb demo.

I had to login as the bot manually in order to accept a conversation with my human account.

After that, the bot responded - but also to itself, forever... See screenshot.

Kinda funny but probably not intended?

Many greetings

@prachita11
Copy link

prachita11 commented Jan 1, 2021

Hey there ! Faced the same issue but was able to fix it by changing the if condition a bit.
if (message.resource.from.indexOf(username) === -1 && message.resource.messagetype !== 'Control/Typing' && message.resource.messagetype !== 'Control/ClearTyping') { var conversationLink = message.resource.conversationLink; var conversationId = conversationLink.substring(conversationLink.lastIndexOf('/') + 1); skyweb.sendMessage(conversationId, message.resource.content + '. Cats will rule the World'); }
The message.resource.from returns a url with the senders id , so index of username seems to not make sense here.
what i did is to slice this string and extract the last few characters which make up the sender id.
let sender =message.resource.from.slice(message.resource.from.length -26 );
and in the login function
we can store the object
var user_info = skyweb.skypeAccount.selfInfo;
and then extract the username field of this object(which is essentially the id)

so the if condition will be
if (user_info.username !== sender && message.resource.messagetype !== 'Control/Typing' && message.resource.messagetype !== 'Control/ClearTyping') { var conversationLink = message.resource.conversationLink; var conversationId = conversationLink.substring(conversationLink.lastIndexOf('/') + 1); skyweb.sendMessage(conversationId, message.resource.content + '. Cats will rule the World'); }

This essentially checks if the message received is sent by you or the other user . if its not sent by you the automated response is emitted to the sender.

Hope this helps :) if there is a cleaner way to do this please let me know .

Regards !

@stefan-reich
Copy link
Author

Cool, that's helpful

@stefan-reich
Copy link
Author

I got it working... learned a bit of TypeScript on the way too. Now I'll wire this demo application to my Java code in some way, and badaboom - Skype bot.

@prachita11
Copy link

prachita11 commented Jan 8, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants