summaryrefslogtreecommitdiff
path: root/notification
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2015-09-28 08:43:46 -0700
committerToshio Kuratomi <a.badger@gmail.com>2015-09-28 08:43:46 -0700
commit3c8c7168014234be339a42481d74f3954d47a4fc (patch)
tree5849ee58e91e28d185815054725044dbff86fe0b /notification
parent4cf2c5555ed7c7c03474d4620c032e56f4a4cae8 (diff)
parent5a4dcc24fc3a64e0c06945484c38bbf12f3415f6 (diff)
downloadansible-modules-extras-3c8c7168014234be339a42481d74f3954d47a4fc.tar.gz
Merge pull request #911 from Jmainguy/irc_part
Adds part=false feature to irc module. This allows people to use a fa…
Diffstat (limited to 'notification')
-rw-r--r--notification/irc.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/notification/irc.py b/notification/irc.py
index 7e34049c..28ad4417 100644
--- a/notification/irc.py
+++ b/notification/irc.py
@@ -89,6 +89,12 @@ options:
- Designates whether TLS/SSL should be used when connecting to the IRC server
default: False
version_added: "1.8"
+ part:
+ description:
+ - Designates whether user should part from channel after sending message or not.
+ Useful for when using a faux bot and not wanting join/parts between messages.
+ default: True
+ version_added: "2.0"
# informational: requirements for nodes
requirements: [ socket ]
@@ -128,7 +134,7 @@ from time import sleep
def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=[], key=None, topic=None,
- nick="ansible", color='none', passwd=False, timeout=30, use_ssl=False):
+ nick="ansible", color='none', passwd=False, timeout=30, use_ssl=False, part=True):
'''send message to IRC'''
colornumbers = {
@@ -194,9 +200,10 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=[], key
if channel:
irc.send('PRIVMSG %s :%s\r\n' % (channel, message))
sleep(1)
- irc.send('PART %s\r\n' % channel)
- irc.send('QUIT\r\n')
- sleep(1)
+ if part:
+ irc.send('PART %s\r\n' % channel)
+ irc.send('QUIT\r\n')
+ sleep(1)
irc.close()
# ===========================================
@@ -219,6 +226,7 @@ def main():
topic=dict(),
passwd=dict(),
timeout=dict(type='int', default=30),
+ part=dict(type='bool', default=True),
use_ssl=dict(type='bool', default=False)
),
supports_check_mode=True,
@@ -239,9 +247,10 @@ def main():
passwd = module.params["passwd"]
timeout = module.params["timeout"]
use_ssl = module.params["use_ssl"]
+ part = module.params["part"]
try:
- send_msg(msg, server, port, channel, nick_to, key, topic, nick, color, passwd, timeout, use_ssl)
+ send_msg(msg, server, port, channel, nick_to, key, topic, nick, color, passwd, timeout, use_ssl, part)
except Exception, e:
module.fail_json(msg="unable to send to IRC: %s" % e)