From e9e1dbf6d80e260cd14e612ebfc7fc382117a753 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 22 Feb 2022 09:07:58 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20m=C3=A9thode=20de=20cr=C3=A9ati?= =?UTF-8?q?on=20d'une=20commande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/protocol/RegexMatcher.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/protocol/RegexMatcher.go b/pkg/protocol/RegexMatcher.go index 0e2774c..ed444cf 100644 --- a/pkg/protocol/RegexMatcher.go +++ b/pkg/protocol/RegexMatcher.go @@ -21,3 +21,14 @@ type RegexMatcher struct { func (m RegexMatcher) Match(data string) bool { return m.matcher.MatchString(data) } + +// Build Permet de construire une chaine respectant une commande. Retourne la chaine et bool (TRUE si correct et FALSE si incorrect) +func (m RegexMatcher) Build(cmd string, datas ...string) (string, bool) { + str := cmd + + for _, data := range datas { + str += " " + data + } + + return str, m.Match(str) +}