From 7aaac8d6981a6a54179c7ae7dec1a479638278de Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 22 Aug 2012 19:19:49 +0200 Subject: [PATCH] weercd.py: add option "nickused" (send some messages 433 before accepting nick) --- test/weercd.conf | 1 + test/weercd.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/weercd.conf b/test/weercd.conf index 6d5a1a457..68c51395c 100644 --- a/test/weercd.conf +++ b/test/weercd.conf @@ -7,6 +7,7 @@ debug=off action=flood wait=0 sleep=0 +nickused=0 maxchans=5 maxnicks=100 usernotices=on diff --git a/test/weercd.py b/test/weercd.py index 35d996163..6efa08579 100755 --- a/test/weercd.py +++ b/test/weercd.py @@ -53,7 +53,7 @@ import sys, socket, select, time, random, string, re NAME = 'weercd' -VERSION = '0.4' +VERSION = '0.5' options = { 'host' : ['', 'Host for socket bind'], @@ -62,6 +62,7 @@ options = { 'action' : ['flood', 'Action of server: "flood" = flood client, "user" = send custom messages to client'], 'wait' : ['0', 'Time to wait before flooding client (float, in seconds)'], 'sleep' : ['0', 'Sleep for select, delay between 2 messages sent to client (float, in seconds)'], + 'nickused' : ['0', 'Send 433 (nickname already in use) this number of times before accepting nick'], 'maxchans' : ['5', 'Max channels to join'], 'maxnicks' : ['100', 'Max nicks per channel'], 'usernotices': ['on', 'Send notices to user (on/off)'], @@ -136,6 +137,7 @@ class Client: self.incount, self.outcount, self.inbytes, self.outbytes = 0, 0, 0, 0 self.quit, self.endmsg, self.endexcept = False, '', None self.sleep = float(getoption('sleep')) + self.nickused = int(getoption('nickused')) self.maxchans = int(getoption('maxchans')) self.maxnicks = int(getoption('maxnicks')) self.usernotices = (getoption('usernotices') == 'on') @@ -199,8 +201,13 @@ class Client: def connect(self): """Tell client that connection is ok.""" try: + count = self.nickused while self.nick == '': self.read(0.1) + if self.nick and count > 0: + self.send(':%s 433 * %s :Nickname is already in use.' % (NAME, self.nick)) + self.nick = '' + count -= 1 self.send(':%s 001 %s :Welcome to the WeeChat IRC flood server' % (NAME, self.nick)) self.send(':%s 002 %s :Your host is %s, running version %s' % (NAME, self.nick, NAME, VERSION)) self.send(':%s 003 %s :Are you solid like a rock?' % (NAME, self.nick))