Commit d935a5eb authored by Romain Bignon's avatar Romain Bignon

channels prefixed with '+' use a different anonymous rule

parent ef7f10c3
......@@ -21,7 +21,7 @@
# USA
VERSION = "0.1"
CHANNEL = "#"
CHANNELS = ["#", "+"]
import datetime
import os
......@@ -32,6 +32,7 @@ import string
import sys
import ssl
import time
from random import choice
from optparse import OptionParser
......@@ -50,6 +51,15 @@ class Channel(object):
if not self.members:
self.server.remove_channel(self)
NICKNAMES = ['Roger', 'Bertrand', 'Gilbert', 'Jocelyne', 'Hector', 'Liliane', 'Patoche']
@property
def anon_prefix(self):
if self.name.startswith('+'):
nickname = choice(self.NICKNAMES)
else:
nickname = datetime.datetime.now().strftime('%H:%M:%S')
return '%s!an@ymo.us' % nickname
def check_registered(func):
def inner(self, *args, **kwargs):
......@@ -86,10 +96,6 @@ class Client(object):
def prefix(self):
return "%s!%s@%s" % (self.nickname, self.user, self.host)
@property
def anon_prefix(self):
return '%s!an@ymo.us' % datetime.datetime.now().strftime('%H:%M:%S')
@property
def registered(self):
return self.nickname and self.user
......@@ -164,7 +170,7 @@ class Client(object):
self.reply("422 %s :MOTD File is missing" % self.nickname)
def message_channel(self, channel, command, message, include_self=False):
line = ":%s %s %s" % (self.anon_prefix, command, message)
line = ":%s %s %s" % (channel.anon_prefix, command, message)
for client in channel.members:
if client != self or include_self:
client.message(line)
......@@ -233,7 +239,8 @@ class Client(object):
% (self.nickname, self.server.name, VERSION))
self.send_lusers()
self.send_motd()
self.join_channel(self.server.get_channel(CHANNEL))
for chan in CHANNELS:
self.join_channel(self.server.get_channel(chan))
def on_nick(self, args):
if len(args) < 1:
......@@ -494,7 +501,8 @@ class Server(object):
print msg
sys.stdout.flush()
def print_error(self, msg):
@classmethod
def print_error(cls, msg):
sys.stderr.write("%s\n" % msg)
def remove_member_from_channel(self, client, channelname):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment