Help - Search - Members - Calendar
Full Version: How to answer a Bot into Multichat
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
AndyS
Hi all,
I´m playing around with a Skype-Bot. (VB, SkypeAPILib)
It works fine. But when my Bot is in a Multichat with more users,
he answers his repeats only directly to the user where the command came from.
I would change him to answer inside the Multichat.

void IncomingMessage(SKYPEAPILib.ChatMessage MessageReceived)
{
string strMessage = MessageReceived.Body.ToString();
string strCommand;
//...
//Bot do something funny
strResponse = //answer from Bot;

m_skype.SendMessageA(MessageReceived.MessageFrom.Handle.ToString(),
strResponse);
// I think, the problem is only in this line. Isn´t it?
}

Thanks,
Andy
TheUberOverlord
QUOTE (AndyS @ Thu May 1 2008, 08:17)
Go to the original post
Hi all,
I´m playing around with a Skype-Bot. (VB, SkypeAPILib)
It works fine. But when my Bot is in a Multichat with more users,
he answers his repeats only directly to the user where the command came from.
I would change him to answer inside the Multichat.

void IncomingMessage(SKYPEAPILib.ChatMessage MessageReceived)
{
string strMessage = MessageReceived.Body.ToString();
string strCommand;
//...
//Bot do something funny
strResponse = //answer from Bot;

m_skype.SendMessageA(MessageReceived.MessageFrom.Handle.ToString(),
strResponse);
// I think, the problem is only in this line. Isn´t it?
}

Thanks,
Andy


You need to send the message to a specific chat.
AndyS
Hi, thanks.

I solved it in the meantime.
smile.png
LoB
How? dull.png
TheUberOverlord
QUOTE (LoB @ Wed Jun 25 2008, 10:00)
Go to the original post
How? dull.png


In C# it would be like this when you received a Message via the MessageStatus Event handler:

CODE
        public static Skype skype = new Skype();
        public static Chat chat = new Chat();
        private string LastSent = "";

        ((_ISkypeEvents_Event)skype).MessageStatus += OurMessageStatus;

        public void OurMessageStatus(ChatMessage chatmessage, TChatMessageStatus status)
        {
            if (LastSent == ichatmessage.Id.ToString())
                {
                    return;
                }

            LastSent = ichatmessage.Id.ToString();

            // Skype Chat Window for this Chat must be minmized
            // or not in focus for this to work. If you looked
            // for a status of TChatMessageStatus.cmsRead you
            // could be sending replies to chat messages days,
            // weeks, months old, that you just READ "looked at"
            // now. You also want to make sure you only started
            // this AFTER the Skype client started and got caught
            // up with any chat message that may have been queued
            // for it otherwise you would respond to many messages
            // that were waiting for you since you logged off.

            // A status of TChatMessageStatus.cmsReceived means
            // the Skype client received and stored the message in
            // the database.

            // A status of TChatMessageStatus.cmsRead means that
            // message has been read by you which could much later.

            // If a Skype chat window is open and in focus when the
            // message is received ONLY a status of cmsRead will be
            // sent.
                    
            // LastSent is used to not process the same message
            // twice. This only works if the last message was the
            // same Id. The same message with a different status
            // will still always have the same message Id.

            // You can see the different message flows when the
            // Skype chat window is maximized and in focus vs
            // minimized using this program:
              
            // http://forum.skype.com/index.php?showtopic=142871

            if ((chatmessage.Type == TChatMessageType.cmeSaid) && (status == TChatMessageStatus.cmsReceived))
                {
                   chat = skype.get_Chat(chatmessage.Chat.Name);
                   chat.SendMessage("Wow Really?");
                }
        }


You can see the different message flows in ANY Skype chat when the Skype chat window is maximized and in focus vs minimized using this program:

http://forum.skype.com/index.php?showtopic=142871
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.