|
|
@ -89,6 +89,12 @@ options:
|
|
|
|
- Designates whether TLS/SSL should be used when connecting to the IRC server
|
|
|
|
- Designates whether TLS/SSL should be used when connecting to the IRC server
|
|
|
|
default: False
|
|
|
|
default: False
|
|
|
|
version_added: "1.8"
|
|
|
|
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
|
|
|
|
# informational: requirements for nodes
|
|
|
|
requirements: [ socket ]
|
|
|
|
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,
|
|
|
|
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'''
|
|
|
|
'''send message to IRC'''
|
|
|
|
|
|
|
|
|
|
|
|
colornumbers = {
|
|
|
|
colornumbers = {
|
|
|
@ -194,9 +200,10 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=[], key
|
|
|
|
if channel:
|
|
|
|
if channel:
|
|
|
|
irc.send('PRIVMSG %s :%s\r\n' % (channel, message))
|
|
|
|
irc.send('PRIVMSG %s :%s\r\n' % (channel, message))
|
|
|
|
sleep(1)
|
|
|
|
sleep(1)
|
|
|
|
irc.send('PART %s\r\n' % channel)
|
|
|
|
if part:
|
|
|
|
irc.send('QUIT\r\n')
|
|
|
|
irc.send('PART %s\r\n' % channel)
|
|
|
|
sleep(1)
|
|
|
|
irc.send('QUIT\r\n')
|
|
|
|
|
|
|
|
sleep(1)
|
|
|
|
irc.close()
|
|
|
|
irc.close()
|
|
|
|
|
|
|
|
|
|
|
|
# ===========================================
|
|
|
|
# ===========================================
|
|
|
@ -219,6 +226,7 @@ def main():
|
|
|
|
topic=dict(),
|
|
|
|
topic=dict(),
|
|
|
|
passwd=dict(),
|
|
|
|
passwd=dict(),
|
|
|
|
timeout=dict(type='int', default=30),
|
|
|
|
timeout=dict(type='int', default=30),
|
|
|
|
|
|
|
|
part=dict(type='bool', default=True),
|
|
|
|
use_ssl=dict(type='bool', default=False)
|
|
|
|
use_ssl=dict(type='bool', default=False)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
|
|
|
supports_check_mode=True,
|
|
|
@ -239,9 +247,10 @@ def main():
|
|
|
|
passwd = module.params["passwd"]
|
|
|
|
passwd = module.params["passwd"]
|
|
|
|
timeout = module.params["timeout"]
|
|
|
|
timeout = module.params["timeout"]
|
|
|
|
use_ssl = module.params["use_ssl"]
|
|
|
|
use_ssl = module.params["use_ssl"]
|
|
|
|
|
|
|
|
part = module.params["part"]
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
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:
|
|
|
|
except Exception, e:
|
|
|
|
module.fail_json(msg="unable to send to IRC: %s" % e)
|
|
|
|
module.fail_json(msg="unable to send to IRC: %s" % e)
|
|
|
|
|
|
|
|
|
|
|
|