[LEDE-DEV] phase1: irc-bot: allow to use noticeOnChannel

Submitted by Alexander Couzens on June 27, 2017, 6:14 p.m.

Details

Message ID 20170627181447.8805-1-lynxis@fe80.eu
State New
Delegated to: Alexander Couzens
Headers show

Commit Message

Alexander Couzens June 27, 2017, 6:14 p.m.
notices are shown in a different color or handled in a
different way on the clients.
---
 phase1/config.ini.example | 1 +
 phase1/master.cfg         | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/phase1/config.ini.example b/phase1/config.ini.example
index bfbe837..f2c15fd 100644
--- a/phase1/config.ini.example
+++ b/phase1/config.ini.example
@@ -18,6 +18,7 @@  port = 6667
 channel = #example-channel
 nickname = example-builder
 password = example
+notice = True
 
 [repo]
 url = https://git.lede-project.org/source.git
diff --git a/phase1/master.cfg b/phase1/master.cfg
index 04879e8..c6fb0c3 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -803,6 +803,7 @@  if ini.has_option("irc", "host") and ini.has_option("irc", "nickname") and ini.h
 	irc_chan = ini.get("irc", "channel")
 	irc_nick = ini.get("irc", "nickname")
 	irc_pass = None
+	irc_notice = False
 
 	if ini.has_option("irc", "port"):
 		irc_port = ini.getint("irc", "port")
@@ -810,13 +811,17 @@  if ini.has_option("irc", "host") and ini.has_option("irc", "nickname") and ini.h
 	if ini.has_option("irc", "password"):
 		irc_pass = ini.get("irc", "password")
 
+	if ini.has_option("irc", "notice")
+		irc_notice = ini.getboolean("irc", "notice")
+
 	irc = words.IRC(irc_host, irc_nick, port = irc_port, password = irc_pass,
 			channels = [{ "channel": irc_chan }],
 			notify_events = {
 			  'exception': 1,
 			  'successToFailure': 1,
 			  'failureToSuccess': 1
-			}
+			},
+			noticeOnChannel=irc_notice
 	)
 
 	c['status'].append(irc)