summaryrefslogtreecommitdiff
path: root/modules/extra/db_mysql.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-11-07 20:51:41 -0500
committerAdam <Adam@anope.org>2010-12-12 19:31:00 -0500
commitac41137ce2741df8faf539e0655a10cd4a8f7e32 (patch)
treeee4fc88bba9eeb24bd6802533d42df05e9ee9e75 /modules/extra/db_mysql.cpp
parent28aba58e250fd6d58b0dff3bbc9ee8bbe172df24 (diff)
Added /ms ignore
Diffstat (limited to 'modules/extra/db_mysql.cpp')
-rw-r--r--modules/extra/db_mysql.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp
index f6e0f8f12..fc9f47df9 100644
--- a/modules/extra/db_mysql.cpp
+++ b/modules/extra/db_mysql.cpp
@@ -905,6 +905,26 @@ class DBMySQL : public Module
FOREACH_RESULT(I_OnDatabaseRead, OnDatabaseRead(params));
}
+ r = SQL->RunQuery("SELECT * FROM `anope_ns_core_metadata`");
+ for (int i = 0; i < r.Rows(); ++i)
+ {
+ NickCore *nc = findcore(r.Get(i, "nick"));
+ if (!nc)
+ continue;
+ if (r.Get(i, "name") == "MEMO_IGNORE")
+ nc->memos.ignores.push_back(r.Get(i, "value").ci_str());
+ }
+
+ r = SQL->RunQuery("SELECT * FROM `anope_cs_info_metadata`");
+ for (int i = 0; i < r.Rows(); ++i)
+ {
+ ChannelInfo *ci = cs_findchan(r.Get(i, "channel"));
+ if (!ci)
+ continue;
+ if (r.Get(i, "name") == "MEMO_IGNORE")
+ ci->memos.ignores.push_back(r.Get(i, "value").ci_str());
+ }
+
return EVENT_STOP;
}
@@ -1073,6 +1093,36 @@ class DBMySQL : public Module
}
}
}
+ else if (service == MemoServ)
+ {
+ if (command.equals_ci("IGNORE") && params.size() > 0)
+ {
+ Anope::string target = params[0];
+ NickCore *nc = NULL;
+ ChannelInfo *ci = NULL;
+ if (target[0] != '#')
+ {
+ target = u->nick;
+ nc = u->Account();
+ if (!nc)
+ return;
+ }
+ else
+ {
+ ci = cs_findchan(target);
+ if (!ci || !check_access(u, ci, CA_MEMO))
+ return;
+ }
+
+ MemoInfo *mi = ci ? &ci->memos : &nc->memos;
+ Anope::string table = ci ? "anope_cs_info_metadata" : "anope_ns_core_metadata";
+ Anope::string ename = ci ? "channel" : "nick";
+
+ this->RunQuery("DELETE FROM `" + table + "` WHERE `" + ename + "` = '" + this->Escape(target) + "' AND `name` = 'MEMO_IGNORE'");
+ for (unsigned j = 0; j < mi->ignores.size(); ++j)
+ this->RunQuery("INSERT INTO `" + table + "` VALUES(" + ename + ", name, value) ('" + this->Escape(target) + "', 'MEMO_IGNORE', '" + this->Escape(mi->ignores[j]) + "')");
+ }
+ }
}
void OnNickAddAccess(NickCore *nc, const Anope::string &entry)