Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Cool Fire
nanobot4
Commits
27177bb5
Commit
27177bb5
authored
Jun 28, 2017
by
Cool Fire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add socketmessage plugin
parent
42e1ccac
Pipeline
#305
failed with stages
in 4 minutes and 42 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
plugins/socketmessage.rb
plugins/socketmessage.rb
+47
-0
No files found.
plugins/socketmessage.rb
0 → 100644
View file @
27177bb5
#!/usr/bin/env ruby
# Plugin to get
class
Socketmessage
require
'socket'
require
'json'
# This method is called when the plugin is first loaded
def
initialize
(
status
,
config
,
output
,
irc
,
timer
)
@status
=
status
@config
=
config
@output
=
output
@irc
=
irc
@timer
=
timer
@server
=
TCPServer
.
open
(
'localhost'
,
2000
)
t
=
Thread
.
new
{
startserver
}
end
# Close server
def
unload
@server
.
close
return
true
end
def
help
(
nick
,
user
,
host
,
from
,
msg
,
arguments
,
con
)
line
=
'This plugin gets messages from a local socket. No interactive commands available'
if
(
con
)
@output
.
c
(
line
+
"
\n
"
)
else
@irc
.
notice
(
nick
,
line
)
end
end
private
def
startserver
loop
do
client
=
@server
.
accept
input
=
JSON
.
parse
client
.
gets
@irc
.
message
(
input
[
'dest'
],
input
[
'message'
]
)
client
.
close
end
end
end
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