Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irker
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iDB
irker
Commits
8c1f62ab
Commit
8c1f62ab
authored
12 years ago
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Make event connections.
parent
f0ad6e12
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
irker.py
+23
-3
23 additions, 3 deletions
irker.py
with
23 additions
and
3 deletions
irker.py
+
23
−
3
View file @
8c1f62ab
...
...
@@ -3,7 +3,11 @@
irker - a simple IRC multiplexer daemon
Takes JSON objects of the form {
'
channel
'
:<channel-url>,
'
message
'
:<text>}
and relays to IRC channels.
and relays messages to IRC channels.
Run this as a daemon in order to maimntain stateful connections to IRC
servers; this will allow it to respond to server pings and minimize
join/leave traffic.
Requires Python 2.6.
...
...
@@ -48,9 +52,9 @@ class Session():
self
.
queue
.
task_done
()
def
name
(
self
):
"
Generate a unique name for this session.
"
return
"
irk
"
+
str
(
Session
.
count
)
return
"
irk
er
"
+
str
(
Session
.
count
)
def
await
(
self
):
"
Block until processing of
the
queue is done.
"
"
Block until processing of
all
queue
d messages
is done.
"
self
.
queue
.
join
()
def
ship
(
self
,
channel
,
message
):
"
Ship a message to the channel.
"
...
...
@@ -61,7 +65,23 @@ class Irker:
"
Persistent IRC multiplexer.
"
def
__init__
(
self
):
self
.
irc
=
irclib
.
IRC
()
self
.
irc
.
add_global_handler
(
"
welcome
"
,
lambda
c
,
e
:
self
.
__on_connect
(
c
,
e
))
self
.
irc
.
add_global_handler
(
"
join
"
,
lambda
c
,
e
:
self
.
__on_join
(
c
,
e
))
self
.
irc
.
add_global_handler
(
"
disconnect
"
,
lambda
c
,
e
:
self
.
__on_quit
(
c
,
e
))
thread
=
threading
.
Thread
(
target
=
self
.
irc
.
process_forever
)
self
.
irc
.
_thread
=
thread
thread
.
daemon
=
True
thread
.
start
()
self
.
sessions
=
{}
def
__on_connect
(
self
,
event
):
pass
def
__on_join
(
self
,
event
):
pass
def
__on_quit
(
self
,
event
):
pass
def
logerr
(
self
,
errmsg
):
"
Log a processing error.
"
sys
.
stderr
.
write
(
"
irker:
"
+
errmsg
+
"
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment