Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
515d10fd
Commit
515d10fd
authored
10 years ago
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8172 from phenomenes/channel-key-parameter
Adds channel key parameter
parents
bc194740
7efd8b61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
library/notification/irc
+14
-3
No files found.
library/notification/irc
View file @
515d10fd
...
...
@@ -57,6 +57,11 @@ options:
description:
- Channel name
required: true
key:
description:
- Channel key
required: false
version_added: 1.7
passwd:
description:
- Server password
...
...
@@ -93,7 +98,7 @@ import socket
from
time
import
sleep
def
send_msg
(
channel
,
msg
,
server
=
'localhost'
,
port
=
'6667'
,
def
send_msg
(
channel
,
msg
,
server
=
'localhost'
,
port
=
'6667'
,
key
=
None
,
nick
=
"ansible"
,
color
=
'none'
,
passwd
=
False
,
timeout
=
30
):
'''send message to IRC'''
...
...
@@ -133,7 +138,11 @@ def send_msg(channel, msg, server='localhost', port='6667',
raise
Exception
(
'Timeout waiting for IRC server welcome response'
)
sleep
(
0.5
)
irc
.
send
(
'JOIN
%
s
\r\n
'
%
channel
)
if
key
:
irc
.
send
(
'JOIN
%
s
%
s
\r\n
'
%
(
channel
,
key
))
else
:
irc
.
send
(
'JOIN
%
s
\r\n
'
%
channel
)
join
=
''
start
=
time
.
time
()
while
1
:
...
...
@@ -166,6 +175,7 @@ def main():
color
=
dict
(
default
=
"none"
,
choices
=
[
"yellow"
,
"red"
,
"green"
,
"blue"
,
"black"
,
"none"
]),
channel
=
dict
(
required
=
True
),
key
=
dict
(),
passwd
=
dict
(),
timeout
=
dict
(
type
=
'int'
,
default
=
30
)
),
...
...
@@ -178,11 +188,12 @@ def main():
msg
=
module
.
params
[
"msg"
]
color
=
module
.
params
[
"color"
]
channel
=
module
.
params
[
"channel"
]
key
=
module
.
params
[
"key"
]
passwd
=
module
.
params
[
"passwd"
]
timeout
=
module
.
params
[
"timeout"
]
try
:
send_msg
(
channel
,
msg
,
server
,
port
,
nick
,
color
,
passwd
,
timeout
)
send_msg
(
channel
,
msg
,
server
,
port
,
key
,
nick
,
color
,
passwd
,
timeout
)
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"unable to send to IRC:
%
s"
%
e
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment