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
1bcb115b
Commit
1bcb115b
authored
12 years ago
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Comment fixes.
parent
cec1128e
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
+11
-4
11 additions, 4 deletions
irker.py
with
11 additions
and
4 deletions
irker.py
+
11
−
4
View file @
1bcb115b
...
...
@@ -11,8 +11,7 @@ join/leave traffic.
Requires Python 2.6.
TO-DO: Is there any way to cope is servers drop connections?
TO-DO: Multiple irkers could try to use the same nick
TO-DO: Is there any way to cope if servers drop connections?
TO-DO: Register the port?
"""
# These things might need tuning
...
...
@@ -26,8 +25,9 @@ NAMESTYLE = "irker%03d" # IRC nick template - must contain '%d'
# No user-serviceable parts below this line
import
os
,
sys
,
json
,
irclib
,
exceptions
,
getopt
,
urlparse
,
time
import
os
,
sys
,
json
,
exceptions
,
getopt
,
urlparse
,
time
,
socket
import
threading
,
Queue
,
SocketServer
import
irclib
class
SessionException
(
exceptions
.
Exception
):
def
__init__
(
self
,
message
):
...
...
@@ -104,6 +104,7 @@ class Irker:
self
.
sessions
=
{}
self
.
countmap
=
{}
self
.
servercount
=
0
self
.
hostname
=
socket
.
getfqdn
()
def
logerr
(
self
,
errmsg
):
"
Log a processing error.
"
sys
.
stderr
.
write
(
"
irker:
"
+
errmsg
+
"
\n
"
)
...
...
@@ -111,6 +112,12 @@ class Irker:
"
Debugging information.
"
if
self
.
debuglevel
>=
level
:
sys
.
stderr
.
write
(
"
irker[%d]: %s
\n
"
%
(
self
.
debuglevel
,
errmsg
))
def
nickname
(
self
,
n
):
"
Return a name for the nth server connection.
"
# The purpose of including the FQDN is to ensure that the nicks
# of bots managed by instances running on different hosts can
# never collide.
return
(
NAMESTYLE
%
n
)
+
"
-
"
+
self
.
hostname
.
replace
(
"
.
"
,
"
-
"
)
def
open
(
self
,
servername
,
port
):
"
Allocate a new server instance.
"
if
not
(
servername
,
port
)
in
self
.
countmap
:
...
...
@@ -121,7 +128,7 @@ class Irker:
newserver
=
self
.
irc
.
server
()
newserver
.
connect
(
servername
,
port
,
NAMESTYLE
%
self
.
servercount
)
self
.
nickname
(
self
.
servercount
)
)
self
.
countmap
[(
servername
,
port
)]
=
(
1
,
newserver
)
return
self
.
countmap
[(
servername
,
port
)][
1
]
def
close
(
self
,
servername
,
port
):
...
...
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