-7

I am making a Skype bot in C# but I'm having a problem. It isn't reading my own commands, only the commands received by others.

When I add something like "!Resolve (username)" it makes the code all bugged up by bugged up i mean it just crashes the tool when i start it.

Could somebody please look and see if there are any major issues.

private Skype skype;
    private const string trigger = "!";
    private const string nick = "The OG Bot";

And this

private string ProcessCommand(string str)
    {
        string result;
        switch (str)
        {
            case "resolve":
                result = "Currently Not Working Will Fix Soon.";
                break;
            case "help":
                result = "Here are some commands you can run. \n !resolve \n !date \n !time \n !who \n !swag \n !ip";
                break;
            case "date":
                result = "Current Date is: " + DateTime.Now.ToLongDateString();
                break;
            case "time":
                result = "Current Time is: " + DateTime.Now.ToLongTimeString();
                break;
            case "who":
                result = "This API was created by TehMerkMods";
                break;
            case "ip":
                result = new WebClient().DownloadString("http://icanhazip.com");
                break;
            case "swag":
                result = "(mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) (mm) ";
                break;
            default:
                result = "Sorry, I do not recognize your command";
                break;
        }

        return result;
    }

And last of all

private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
    {
        if (TChatMessageStatus.cmsRead == status)
        {
            return;
        }

        if (msg.Body.IndexOf(trigger) == 0 && TChatMessageStatus.cmsReceived == status)
        {
            string command = msg.Body.Remove(0, trigger.Length).ToLower();
            skype.SendMessage(msg.Sender.Handle, nick + " : " + ProcessCommand(command));
        }
    }
  • 1
    What do you mean it "makes the code all bugged up"? Please describe the behavior you are expecting and the behavior you are seeing. We need details. –  Mar 27 '15 at 21:21
  • @Amy Well basically it doesn't grab the functions after that it just gives me a build error basically it cannot read my own commands what ever i do but reads other users sent commands just fine – TehMerkMods Mar 27 '15 at 21:47
  • 2
    Could you please post the error that you are receiving when it crashes? – John Odom Mar 27 '15 at 21:49
  • 1
    You're getting a build error? **What build error?** When I said we need details, I meant that you need to provide us with details. **Be specific, not vague.** –  Mar 27 '15 at 22:51

2 Answers2

1

You are only getting 'received', you need to get 'send' also

Example:

if (TChatMessageStatus.cmsReceived Or Status = TChatMessageStatus.cmsSent)
wtm
  • 166
  • 1
  • 13
0

You have an if statement in the last section of code that is only looking for the TChatMessageStatus.cmsReceived. This statement will never be true when you send a message because you don't receive your own messages.

As for the program crashing... you need to give more information.

Martouf
  • 1
  • 1