Sfoglia il codice sorgente

feat: support trigger off multi #action for one line

dzp 3 anni fa
parent
commit
94820e5e3b
3 ha cambiato i file con 39 aggiunte e 0 eliminazioni
  1. 32 0
      src/config.c
  2. 1 0
      src/tintin.h
  3. 6 0
      src/trigger.c

+ 32 - 0
src/config.c

@@ -61,6 +61,7 @@ DO_CONFIG(config_verbatimchar);
 DO_CONFIG(config_verbose);
 DO_CONFIG(config_wordwrap);
 DO_CONFIG(config_iac_ga);
+DO_CONFIG(config_multi_trigger);
 
 typedef struct session *CONFIG  (struct session *ses, char *arg1, char *arg2, int index);
 
@@ -312,6 +313,13 @@ struct config_type config_table[] =
 		config_iac_ga
 	},
 
+	{
+		"MULTI TRIGGER",
+		"Trigger off all #action that matched server output",
+		"Just trigger off one #action only",
+		config_multi_trigger
+	},
+
 	{
 		"",
 		"",
@@ -1376,3 +1384,27 @@ DO_CONFIG(config_iac_ga)
 
 	return ses;
 }
+
+DO_CONFIG(config_multi_trigger)
+{
+	if (*arg2)
+	{
+		if (is_abbrev(arg2, "ON"))
+		{
+			SET_BIT(ses->config_flags, CONFIG_FLAG_MULTI_TRIGGER);
+		}
+		else if (is_abbrev(arg2, "OFF"))
+		{
+			DEL_BIT(ses->config_flags, CONFIG_FLAG_MULTI_TRIGGER);
+		}
+		else
+		{
+			show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
+
+			return NULL;
+		}
+	}
+	strcpy(arg2, HAS_BIT(ses->config_flags, CONFIG_FLAG_MULTI_TRIGGER) ? "ON" : "OFF");
+
+	return ses;
+}

+ 1 - 0
src/tintin.h

@@ -648,6 +648,7 @@ enum operators
 #define CONFIG_FLAG_VERBOSE           BV18
 #define CONFIG_FLAG_WORDWRAP          BV19
 #define CONFIG_FLAG_IAC_GA            BV30
+#define CONFIG_FLAG_MULTI_TRIGGER     BV31
 
 
 #define SES_FLAG_BUFFERUPDATE         BV01

+ 6 - 0
src/trigger.c

@@ -94,6 +94,12 @@ void check_all_actions(struct session *ses, char *original, char *line, char *bu
 
 			script_driver(ses, LIST_ACTION, buf);
 
+			if (HAS_BIT(ses->config_flags, CONFIG_FLAG_MULTI_TRIGGER))
+			{
+				DEL_BIT(ses->config_flags, CONFIG_FLAG_MULTI_TRIGGER);
+				continue;
+			}
+
 			return;
 		}
 	}