Don't send JOIN and PART commands if channel is not set (#62334)
Currently, the irc module is sending JOIN and PART commands even if the channel key is not set in the irc module. This causes the module to send JOIN and PART commands to the #None channel. This module can send PRIVMSGs to either a channel or a list of nicks, so sending JOIN and PART doesn't make sense in cases where channel is undefined. The same goes for the TOPIC command, which is used to set a topic for channels. This patch ensures that the JOIN, PART and TOPIC commands are only sent if the channel is defined.
This commit is contained in:
parent
cc86748109
commit
807f4ea658
1 changed files with 21 additions and 19 deletions
|
@ -17,9 +17,9 @@ DOCUMENTATION = '''
|
|||
---
|
||||
module: irc
|
||||
version_added: "1.2"
|
||||
short_description: Send a message to an IRC channel
|
||||
short_description: Send a message to an IRC channel or a nick
|
||||
description:
|
||||
- Send a message to an IRC channel. This is a very simplistic implementation.
|
||||
- Send a message to an IRC channel or a nick. This is a very simplistic implementation.
|
||||
options:
|
||||
server:
|
||||
description:
|
||||
|
@ -204,6 +204,7 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=None, k
|
|||
raise Exception('Timeout waiting for IRC server welcome response')
|
||||
time.sleep(0.5)
|
||||
|
||||
if channel:
|
||||
if key:
|
||||
irc.send(to_bytes('JOIN %s %s\r\n' % (channel, key)))
|
||||
else:
|
||||
|
@ -230,6 +231,7 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=None, k
|
|||
irc.send(to_bytes('PRIVMSG %s :%s\r\n' % (channel, message)))
|
||||
time.sleep(1)
|
||||
if part:
|
||||
if channel:
|
||||
irc.send(to_bytes('PART %s\r\n' % channel))
|
||||
irc.send(to_bytes('QUIT\r\n'))
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Reference in a new issue