Receiving the same message twice

2019-09-11 05:27发布

Hey i'm building a skypebot and i can't figure out why i'm receiving the message 2x

This is the code im using

        private void Form1_Load(object sender, EventArgs e)
    {
        client = new Skype();
        client.MessageStatus += Client_MessageStatus;
        AttachToSkype();
    }
        private void Client_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
    {
        MessageBox.Show(pMessage.Sender.Handle + " Says: " + pMessage.Body);
    }

Thanks for your time -Tristan

1条回答
Anthone
2楼-- · 2019-09-11 05:38

MessageStatus event is called every time message's status has been changed.
You need check for TChatMessageStatus. It should be cmsReceived.

private static void Skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status)
{
       if (Status != TChatMessageStatus.cmsReceived) return;

       MessageBox.Show(pMessage.Sender.Handle + " Says: " + pMessage.Body);
}
查看更多
登录 后发表回答