mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #6289 from rawtaz/fix-irc-nicklen
Make irc module accept the nick being shortened by the server.
This commit is contained in:
commit
1211160cdb
1 changed files with 6 additions and 2 deletions
|
@ -39,7 +39,7 @@ options:
|
||||||
default: 6667
|
default: 6667
|
||||||
nick:
|
nick:
|
||||||
description:
|
description:
|
||||||
- Nickname
|
- Nickname. May be shortened, depending on server's NICKLEN setting.
|
||||||
required: false
|
required: false
|
||||||
default: ansible
|
default: ansible
|
||||||
msg:
|
msg:
|
||||||
|
@ -122,7 +122,11 @@ def send_msg(channel, msg, server='localhost', port='6667',
|
||||||
start = time.time()
|
start = time.time()
|
||||||
while 1:
|
while 1:
|
||||||
motd += irc.recv(1024)
|
motd += irc.recv(1024)
|
||||||
if re.search('^:\S+ 00[1-4] %s :' % nick, motd, flags=re.M):
|
# The server might send back a shorter nick than we specified (due to NICKLEN),
|
||||||
|
# so grab that and use it from now on (assuming we find the 00[1-4] response).
|
||||||
|
match = re.search('^:\S+ 00[1-4] (?P<nick>\S+) :', motd, flags=re.M)
|
||||||
|
if match:
|
||||||
|
nick = match.group('nick')
|
||||||
break
|
break
|
||||||
elif time.time() - start > timeout:
|
elif time.time() - start > timeout:
|
||||||
raise Exception('Timeout waiting for IRC server welcome response')
|
raise Exception('Timeout waiting for IRC server welcome response')
|
||||||
|
|
Loading…
Reference in a new issue