Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • weechat/weercd
1 result
Show changes
Commits on Source (2)
Loading
Loading
@@ -56,7 +56,7 @@ Yeah, it's stable! \o/
 
== Copyright
 
Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
Copyright (C) 2011-2018 Sébastien Helleu <flashcode@flashtux.org>
 
This file is part of weercd, the WeeChat IRC testing server.
 
Loading
Loading
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2018 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of weercd, the WeeChat IRC testing server.
#
Loading
Loading
@@ -38,7 +38,7 @@ import time
import traceback
 
NAME = 'weercd'
VERSION = '0.8'
VERSION = '0.9'
 
 
def fuzzy_string(minlength=1, maxlength=50, spaces=False):
Loading
Loading
@@ -115,8 +115,7 @@ class Client(object): # pylint: disable=too-many-instance-attributes
if with_number:
self.nicknumber += 1
return '{0}{1}'.format(fuzzy_string(1, 5), self.nicknumber)
else:
return fuzzy_string(1, 10)
return fuzzy_string(1, 10)
 
def send(self, data):
"""Send one message to client."""
Loading
Loading
@@ -239,7 +238,7 @@ class Client(object): # pylint: disable=too-many-instance-attributes
 
def flood_channel_part(self, channel):
"""Part or quit of a user in a channel."""
if len(self.channels[channel]) == 0:
if not self.channels[channel]:
return
rnick = self.channel_random_nick(channel)
if not rnick:
Loading
Loading
@@ -254,7 +253,7 @@ class Client(object): # pylint: disable=too-many-instance-attributes
 
def flood_channel_kick(self, channel):
"""Kick of a user in a channel."""
if len(self.channels[channel]) == 0:
if not self.channels[channel]:
return
rnick1 = self.channel_random_nick(channel)
rnick2 = self.channel_random_nick(channel)
Loading
Loading
@@ -266,7 +265,7 @@ class Client(object): # pylint: disable=too-many-instance-attributes
 
def flood_channel_message(self, channel):
"""Message from a user in a channel."""
if len(self.channels[channel]) == 0:
if not self.channels[channel]:
return
rnick = self.channel_random_nick(channel)
if not rnick:
Loading
Loading
@@ -324,7 +323,8 @@ class Client(object): # pylint: disable=too-many-instance-attributes
while True:
# display the prompt if we are reading in stdin
if stdin:
sys.stdout.write('Message to send to client: ')
sys.stdout.write('Message to send to client '
'(/help for help): ')
sys.stdout.flush()
message = self.args.file.readline()
if not message:
Loading
Loading
@@ -332,9 +332,14 @@ class Client(object): # pylint: disable=too-many-instance-attributes
if sys.version_info < (3,):
message = message.decode('UTF-8')
message = message.rstrip('\n')
if message and not message.startswith('//'):
self.send(message.format(self=self))
count += 1
if message:
if message.startswith('/') and message[1:2] != '/':
command = message[1:]
if command == 'help':
pass
elif not message.startswith('//'):
self.send(message.format(self=self))
count += 1
self.read(0.1 if stdin else self.args.sleep)
except IOError as exc:
self.endmsg = 'unable to read file {0}'.format(self.args.file)
Loading
Loading