Changeset f4d32cd for commands.c


Ignore:
Timestamp:
Jan 10, 2007, 3:03:48 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5551208
Parents:
d609dd6
git-author:
Nelson Elhage <nelhage@mit.edu> (01/10/07 15:02:27)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/10/07 15:03:48)
Message:
Adding infrastructure for admin messages that are questions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rfe0a16a rf4d32cd  
    731731              "Display an informatative message",
    732732              "message <message>",
     733              ""),
     734
     735  OWLCMD_VOID("yes", owl_command_yes, OWL_CTX_RECV,
     736              "Answer yes to a question",
     737              "yes",
     738              ""),
     739
     740  OWLCMD_VOID("no", owl_command_no, OWL_CTX_RECV,
     741              "Answer no to a question",
     742              "no",
    733743              ""),
    734744
     
    24302440}
    24312441
     2442void owl_command_yes(void)
     2443{
     2444  owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
     2445                                        owl_global_get_curmsg(&g));
     2446  if(!owl_message_is_question(m)) {
     2447    owl_function_error("That message isn't a question.");
     2448    return NULL;
     2449  }
     2450  if(owl_message_is_answered(m)) {
     2451    owl_function_error("You already answered that question.");
     2452    return NULL;
     2453  }
     2454  char * cmd = owl_message_get_attribute_value(m, "yescommand");
     2455  if(!cmd) {
     2456    owl_function_error("No yes command!");
     2457    return NULL;
     2458  }
     2459
     2460  owl_function_command_norv(cmd);
     2461  owl_message_set_isanswered(m);
     2462}
     2463
     2464char *owl_command_no(void)
     2465{
     2466  owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
     2467                                        owl_global_get_curmsg(&g));
     2468  if(!owl_message_is_question(m)) {
     2469    owl_function_error("That message isn't a question.");
     2470    return NULL;
     2471  }
     2472  if(owl_message_is_answered(m)) {
     2473    owl_function_error("You already answered that question.");
     2474    return NULL;
     2475  }
     2476  char * cmd = owl_message_get_attribute_value(m, "nocommand");
     2477  if(!cmd) {
     2478    owl_function_error("No no command!");
     2479    return NULL;
     2480  }
     2481
     2482  owl_function_command_norv(cmd);
     2483  owl_message_set_isanswered(m);
     2484}
     2485
    24322486/*********************************************************************/
    24332487/************************** EDIT SPECIFIC ****************************/
Note: See TracChangeset for help on using the changeset viewer.