From 74deb998223ca04756660a27f9d5edd6fb59b21b Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Sun, 20 Apr 2014 12:48:07 +0200 Subject: [PATCH 1/2] Configurable command token Sometimes you might not want just an exclamation mark. Exclamation mark is still the default, your desired command token can be specified in the configuration (config.py). --- brutal/core/bot.py | 3 ++- brutal/core/models.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/brutal/core/bot.py b/brutal/core/bot.py index 73f3e23..911dbf2 100644 --- a/brutal/core/bot.py +++ b/brutal/core/bot.py @@ -12,7 +12,7 @@ class Bot(object): - def __init__(self, nick, connections, *args, **kwargs): + def __init__(self, nick, connections, command_token='!', *args, **kwargs): """ acts as a connection manager, middle man for incoming events, and processor of outgoing actions. """ @@ -22,6 +22,7 @@ def __init__(self, nick, connections, *args, **kwargs): # bot id self.nick = nick self.id = str(uuid.uuid1()) + self.command_token = command_token self.log = logging.getLogger('{0}.{1}.{2}'.format(self.__class__.__module__, self.__class__.__name__, self.nick)) self.log.info('starting bot') diff --git a/brutal/core/models.py b/brutal/core/models.py index c6085de..5ae188b 100644 --- a/brutal/core/models.py +++ b/brutal/core/models.py @@ -130,7 +130,7 @@ def parse_details(self): self.from_bot = False if self.event_type == 'message' and isinstance(self.meta, dict) and 'body' in self.meta: - res = self.parse_event_cmd(self.meta['body']) + res = self.parse_event_cmd(self.meta['body'], self.source_bot.command_token) # if res is False: # self.log.debug('event not parsed as a command') @@ -290,4 +290,4 @@ def part(self, channel, msg=None): self.type = 'part' if msg is not None: self._add_to_meta('msg', msg) - return self \ No newline at end of file + return self From efe08970e5a4d2c1a16e5b29cdbf20eb64e9ccf5 Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Sun, 20 Apr 2014 12:57:48 +0200 Subject: [PATCH 2/2] Command token example specified in config.py spawn --- brutal/spawn/spawn_template/spawn_name/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/brutal/spawn/spawn_template/spawn_name/config.py b/brutal/spawn/spawn_template/spawn_name/config.py index f56d170..7ff7af8 100644 --- a/brutal/spawn/spawn_template/spawn_name/config.py +++ b/brutal/spawn/spawn_template/spawn_name/config.py @@ -48,6 +48,7 @@ # 'channels': ['room', ('private_room', 'pass')] # } # ], - # 'plugin_settings': {} + # 'plugin_settings': {}, + # 'command_token': '.' # } -] \ No newline at end of file +]