-void *answerscripts_process_message(void *conv) {
- FILE* pipe = popen(hook_script, "r"); //TODO: process scripts and send response asynchronously
- while (pipe && fgets(response, RESPONSE_LINE_LENGTH, pipe)) {
+typedef struct {
+ FILE *pipe;
+ PurpleConversation *conv;
+} answerscripts_job;
+
+int answerscripts_process_message_cb(answerscripts_job *job) {
+ FILE *pipe = job->pipe;
+ PurpleConversation *conv = job->conv;
+
+ if (pipe && !feof(pipe)) {
+ if(!fgets(response, ANSWERSCRIPTS_LINE_LENGTH, pipe)
+ && (errno == EWOULDBLOCK || errno == EAGAIN)
+ ) return 1;
+