0
다른 프로토콜에 거의 ID를 기록하지 않고 메시지를 받고 다른 메시지 (명령)에 대한 응답을 제공하는 프로그램을 만들고 싶습니다.received-im-msg 신호 메시지
예 :
나 : 사람
봇 : 나는 libpurple 전원 봇입니다. 나를 위해
static void received_im_msg(PurpleAccount *account, char *sender, char *message, PurpleConversation *conv, PurpleMessageFlags flags) { if (conv==NULL) { conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender); } printf("%s: %s\n", sender, message); char *answer; if (message == "who") { answer="I'm a libpurple powered bot."; } else if (message=="hello") { answer="Hello, my firend!"; } else { answer="Unknown command."; } //print the answer, so we can see it in terminal: printf("bot: %s\n",message); //send the message: purple_conv_im_send(purple_conversation_get_im_data(conv),answer); }
는,이 코드는 단지 확인을 보이지만, 예상대로 작동하지 않습니다
코드는 다음과 같습니다. 봇이받는 모든 메시지는 항상 알 수없는 명령입니다..
example_id_345 :
message == "who"
은 사실이 아니다 왜 같은 경우에도
printf("%s: %s\n", sender, message);
인쇄 뭔가를 이해할 수 없습니다.
왜 이런 일이 발생했는지 알고 있습니까? 내가 뭘 잘못 했니?
나쁜 영어로 죄송합니다. 포인터가 당신이 원하는하지 않은, 같은 주소를 유지
if (strcmp(message, "who") == 0) {
answer="I'm a libpurple powered bot.";
} else if (strcmp(message, "hello") == 0) {
==
검사 :
작동합니다. 고마워요! –