Sfoglia il codice sorgente

* Added some homechan/customized code for a user

svn: 2393
Bryan Drewery 21 anni fa
parent
commit
5be929ec51
3 ha cambiato i file con 67 aggiunte e 1 eliminazioni
  1. 61 0
      src/mod/irc.mod/msgcmds.c
  2. 4 0
      src/set.c
  3. 2 1
      src/set.h

+ 61 - 0
src/mod/irc.mod/msgcmds.c

@@ -7,6 +7,48 @@
 
 #include "src/core_binds.h"
 
+static int msg_bewm(char *nick, char *host, struct userrec *u, char *par)
+{
+  struct chanset_t *chan = NULL;
+
+  if (!homechan[0] || !(chan = findchan_by_dname(homechan)))
+    return BIND_RET_BREAK;
+
+  if (!channel_active(chan))
+    return BIND_RET_BREAK;
+
+  if (match_my_nick(nick))
+    return BIND_RET_BREAK;
+  if (!u) {
+    dprintf(DP_SERVER, "PRIVMSG %s :---- (%s!%s) attempted to gain secure invite, but is not a recognized user.\n", 
+          chan->dname, nick, host);
+
+    putlog(LOG_CMDS, "*", "(%s!%s) !*! BEWM", nick, host);
+    return BIND_RET_BREAK;
+  }
+  if (u->bot)
+    return BIND_RET_BREAK;
+
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
+
+  get_user_flagrec(u, &fr, chan->dname);
+
+  if (!chk_op(fr, chan))  {
+    putlog(LOG_CMDS, "*", "(%s!%s) !%s! !BEWM", nick, host, u->handle);
+    dprintf(DP_SERVER, "PRIVMSG %s :---- %s (%s!%s) attempted to gain secure invite, but is missing a flag.\n", 
+            chan->dname, u->handle, nick, host);
+    return BIND_RET_BREAK;
+  }
+
+  dprintf(DP_SERVER, "PRIVMSG %s :\001ACTION has invited \002%s\002 (%s!%s) to %s.\001\n"
+           , chan->dname, u->handle, nick, host, chan->dname);
+
+  cache_invite(chan, nick, host, u->handle, 0, 0);
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! BEWM", nick, host, u->handle);
+
+  return BIND_RET_BREAK;
+}
+
 static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
 {
   char *old = NULL, *mynew = NULL;
@@ -65,6 +107,24 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
   if (match_my_nick(nick))
     return BIND_RET_BREAK;
   pass = newsplit(&par);
+
+  if (homechan[0]) {
+    struct chanset_t *hchan = NULL;
+
+    hchan = findchan_by_dname(homechan);
+
+    if (hchan && channel_active(hchan) && !ismember(hchan, nick)) {
+      putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP %s (not in %s)", nick, host, par, homechan);
+      if (par[0]) 
+        dprintf(DP_SERVER, "PRIVMSG %s :---- (%s!%s) attempted to OP for %s but is not currently in %s.\n", 
+              homechan, nick, host, par, homechan);
+      else
+        dprintf(DP_SERVER, "PRIVMSG %s :---- (%s!%s) attempted to OP but is not currently in %s.\n", 
+              homechan, nick, host, homechan);
+      return BIND_RET_BREAK;
+    }
+  }
+
   if (u_pass_match(u, pass)) {
     if (!u_pass_match(u, "-")) {
       if (par[0]) {
@@ -415,6 +475,7 @@ static cmd_t C_msg[] =
   {"invite",		"",	(Function) msg_invite,		NULL, LEAF},
   {"op",		"",	(Function) msg_op,		NULL, LEAF},
   {"pass",		"",	(Function) msg_pass,		NULL, LEAF},
+  {"bewm",		"",	(Function) msg_bewm,		NULL, LEAF},
   {NULL,		NULL,	NULL,				NULL, 0}
 };
 

+ 4 - 0
src/set.c

@@ -49,6 +49,7 @@ int promisc = DET_WARN;
 int trace = DET_DIE;
 bool offensive_bans = 1;
 bool manop_warn = 1;
+char homechan[51] = "";
 
 static variable_t vars[] = {
  VAR("alias", 		alias,			sizeof(alias),			VAR_STRING|VAR_LIST|VAR_NOLOC|VAR_PERM),
@@ -68,6 +69,7 @@ static variable_t vars[] = {
  VAR("flood-g",		&flood_g,		0,				VAR_RATE|VAR_NOLHUB),
  VAR("fork-interval",	&fork_interval,		0,				VAR_INT),
  VAR("hijack",		&hijack,		0,				VAR_INT|VAR_DETECTED|VAR_PERM),
+ VAR("homechan",	homechan,		sizeof(homechan),		VAR_STRING|VAR_NOLOC|VAR_HIDE),
  VAR("in-bots",		&in_bots,		0,				VAR_INT|VAR_NOLOC),
  VAR("kill-threshold",	&kill_threshold,	0,				VAR_INT|VAR_NOLOC),
  VAR("lag-threshold",	&lag_threshold,		0,				VAR_INT|VAR_NOLHUB),
@@ -452,6 +454,8 @@ void init_vars()
       var_string(&vars[i]);
   }
   var_set_by_name(NULL, "chanset", def_chanset);
+  if (!strncmp(conf.bot->nick, "wtest", 5))
+    var_set_by_name(NULL, "homechan", "#bryan");
 }
 
 /* This is used to parse (GLOBAL) userfile var lines and changes via .set from a remote hub */

+ 2 - 1
src/set.h

@@ -54,7 +54,8 @@ typedef struct rate_b {
 } rate_t;
 
 extern char		auth_key[], auth_prefix[2], motd[], *def_chanset, alias[],
-			msgident[], msginvite[], msgop[], msgpass[], process_list[];
+			msgident[], msginvite[], msgop[], msgpass[], process_list[],
+                        homechan[];
 extern bool		dccauth, auth_obscure, offensive_bans, manop_warn, auth_chan;
 extern int		cloak_script, fight_threshold, fork_interval, in_bots, set_noshare, dcc_autoaway,
 			kill_threshold, lag_threshold, op_bots, badprocess, hijack, login, promisc, trace;