]> jfr.im git - irc/evilnet/x3.git/commitdiff
basic history command
authorsirvulcan <redacted>
Tue, 20 Jun 2006 06:11:08 +0000 (06:11 +0000)
committersirvulcan <redacted>
Tue, 20 Jun 2006 06:11:08 +0000 (06:11 +0000)
ChangeLog
src/mod-memoserv.c
src/mod-memoserv.help

index 1ba1a2d4a8c1fa2e6b3ed5d21a728fa6c3388fe9..4c05dcfa2e4d289e0fb60d137dcc39471c7108af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 /***********************************************************************
  X3 ChangeLog
 
+2006-06-20  Neil Spierling <sirvulcan@gmail.com>
+
+       * src/mod-memoserv.c: Added basic HISTORY command. At the moment
+       if the recipient deletes the memo it will not be listed in the
+       HISTORY list.
+
+       * src/mod-memoserv.help: HISTORY entry.
+
 2006-06-20  Neil Spierling <sirvulcan@gmail.com>
 
        * src/mod-memoserv.c: Added new flags, see below.
index fbfc3691dff459950d9bb332da5ec24918ebd596..caf104301b7dcdffb439b8e8f0609198d4958839 100644 (file)
@@ -64,8 +64,10 @@ static const struct message_entry msgtab[] = {
     { "MSMSG_NO_MESSAGES", "You have no messages." },
     { "MSMSG_MEMOS_FOUND", "Found $b%d$b matches.\nUse /msg $S READ <ID> to read a message." },
     { "MSMSG_CLEAN_INBOX", "You have $b%d$b or more messages, please clean out your inbox.\nUse /msg $S READ <ID> to read a message." },
-    { "MSMSG_LIST_HEAD",   "$bID$b   $bFrom$b       $bTime Sent$b" },
-    { "MSMSG_LIST_FORMAT", "%-2u     %s $b%s$b          %s" },
+    { "MSMSG_LIST_HEAD",      "$bID$b   $bFrom$b       $bTime Sent$b" },
+    { "MSMSG_LIST_FORMAT",    "%-2u     %s $b%s$b          %s" },
+    { "MSMSG_HISTORY_HEADER", "$bID$b   $bTo$b          $bTime Sent$b" },
+    { "MSMSG_HISTORY_FORMAT", "%-2u     %s              %s" },
     { "MSMSG_MEMO_HEAD", "Memo %u From $b%s$b, received on %s:" },
     { "MSMSG_MEMO_RECIEPT", "$bRead Reciept$b requested, %s." },
     { "MSMSG_BAD_MESSAGE_ID", "$b%s$b is not a valid message ID (it should be a number between 0 and %u)." },
@@ -394,6 +396,47 @@ static MODCMD_FUNC(cmd_list)
     return 1;
 }
 
+static MODCMD_FUNC(cmd_history)
+{
+    struct memo_account *ma;
+    struct memo *memo;
+    dict_iterator_t it;
+    unsigned int ii = 0;
+    unsigned int cc = 0;
+    char posted[24];
+    struct tm tm;
+
+    if (!(ma = memoserv_get_account(user->handle_info)))
+        return 0;
+
+    reply("MSMSG_HISTORY_HEADER");
+
+    if(user->handle_info && user->handle_info->userlist_style != HI_STYLE_CLEAN)
+        reply("MSMSG_BAR");
+
+    for (it = dict_first(memos); it; it = iter_next(it)) {
+        ma = iter_data(it);
+        for (ii = 0; ii < ma->recvd.used; ++ii) {
+            memo = ma->recvd.list[ii];
+            if (!strcasecmp(memo->sender->handle->handle, user->handle_info->handle)) {
+                cc++;
+                localtime_r(&memo->sent, &tm);
+                strftime(posted, sizeof(posted), "%I:%M %p, %m/%d/%Y", &tm);
+                reply("MSMSG_HISTORY_FORMAT", memo->id, memo->sender->handle->handle, posted);
+            }
+        }
+    }
+
+    if (cc == 0)
+        reply("MSG_NONE");
+    else
+        reply("MSMSG_MEMOS_FOUND", cc);
+
+    reply("MSMSG_LIST_END");
+
+    return 1;
+}
+
 static MODCMD_FUNC(cmd_read)
 {
     struct memo_account *ma;
@@ -1029,16 +1072,17 @@ memoserv_init(void)
     saxdb_register("MemoServ", memoserv_saxdb_read, memoserv_saxdb_write);
 
     memoserv_module = module_register("MemoServ", MS_LOG, "mod-memoserv.help", NULL);
-    modcmd_register(memoserv_module, "send",   cmd_send,   3, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "list",   cmd_list,   1, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "read",   cmd_read,   2, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "delete", cmd_delete, 2, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "cancel", cmd_cancel, 2, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "expire", cmd_expire, 1, MODCMD_REQUIRE_AUTHED, "flags", "+oper", NULL);
-    modcmd_register(memoserv_module, "expiry", cmd_expiry, 1,                        0, NULL);
-    modcmd_register(memoserv_module, "status", cmd_status, 1,                        0, NULL);
-    modcmd_register(memoserv_module, "set",    cmd_set,    1, MODCMD_REQUIRE_AUTHED, NULL);
-    modcmd_register(memoserv_module, "oset",   cmd_oset,   1, MODCMD_REQUIRE_AUTHED, "flags", "+helping", NULL);
+    modcmd_register(memoserv_module, "send",    cmd_send,    3, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "list",    cmd_list,    1, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "read",    cmd_read,    2, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "delete",  cmd_delete,  2, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "cancel",  cmd_cancel,  2, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "history", cmd_history, 1, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "expire",  cmd_expire,  1, MODCMD_REQUIRE_AUTHED, "flags", "+oper", NULL);
+    modcmd_register(memoserv_module, "expiry",  cmd_expiry,  1,                        0, NULL);
+    modcmd_register(memoserv_module, "status",  cmd_status,  1,                        0, NULL);
+    modcmd_register(memoserv_module, "set",     cmd_set,     1, MODCMD_REQUIRE_AUTHED, NULL);
+    modcmd_register(memoserv_module, "oset",    cmd_oset,    1, MODCMD_REQUIRE_AUTHED, "flags", "+helping", NULL);
 
     memoserv_opt_dict = dict_new();
     dict_insert(memoserv_opt_dict, "AUTHNOTIFY", opt_authnotify);
index 305deeb2cfbe279c125e5ae9d5eecdebcb1ba6d3..fc2aea93cdecaceeb530a3e0d6b22e90d29346b8 100644 (file)
@@ -11,6 +11,7 @@
         "  $bDELETE$b  - Deletes a message.",
         "  $bLIST$b    - Lists your messages.",
         "  $bCANCEL$b  - Cancels a message you have sent.",
+        "  $bHISTORY$b - Lists any existing memos that you have sent.",
         "  $bSET$b     - Sets certain options in relation with $S.",
         "  $bEXPIRY$b  - Displays when old unread messages will be deleted.",
         "  $bSTATUS$b  - Displays a few details about $S's status.",
@@ -54,6 +55,9 @@
 "CANCEL" ("/msg $S CANCEL <id>",
          "Cancels the messaged marked with <id> as long as you have sent the message.");
 
+"HISTORY" ("/msg $S HISTORY",
+         "Shows you any messages that you have sent, provided that the recipient has not deleted them yet..");
+
 "SEND" ("/msg $S SEND <nick|*account> <-flags> <message>",
         "Sends a message to an user. Flags can be $br$b to request a read reciept. Take note of the ID number if you wish to cancel the message in the future. The ID number is required in the CANCEL command.",
         "You may use *Account instead of Nick as the name argument; the * makes $S use the name of an account directly (useful if the user is not online).",