diff --git a/modules/scripts.py b/modules/scripts.py index c9965cd8..915cea62 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -1,6 +1,6 @@ import glob, json, os, subprocess -from src import Utils +from src import IRCObject, Utils class Module(object): def __init__(self, bot, events, exports): @@ -37,6 +37,8 @@ class Module(object): env[key.upper()] = str(int(value)) elif isinstance(value, (list, dict)): env[key.upper()] = json.dumps(value) + elif isinstance(value, (IRCObject.Object,)): + env[key.upper()] = str(value) proc = subprocess.Popen([filename], stdout=subprocess.PIPE, env=env) try: diff --git a/src/IRCChannel.py b/src/IRCChannel.py index 31c3ee19..78484a66 100644 --- a/src/IRCChannel.py +++ b/src/IRCChannel.py @@ -1,7 +1,7 @@ import uuid -from . import IRCBuffer, Utils +from . import IRCBuffer, IRCObject, Utils -class Channel(object): +class Channel(IRCObject.Object): def __init__(self, name, id, server, bot): self.name = Utils.irc_lower(server, name) self.id = id @@ -19,6 +19,8 @@ class Channel(object): def __repr__(self): return "IRCChannel.Channel(%s|%s)" % (self.server.name, self.name) + def __str__(self): + return self.name def set_topic(self, topic): self.topic = topic diff --git a/src/IRCServer.py b/src/IRCServer.py index a45da3fb..cb47cfb8 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -1,12 +1,12 @@ import collections, socket, ssl, sys, time -from . import IRCChannel, IRCUser, Utils +from . import IRCChannel, IRCObject, IRCUser, Utils THROTTLE_LINES = 4 THROTTLE_SECONDS = 1 READ_TIMEOUT_SECONDS = 120 PING_INTERVAL_SECONDS = 30 -class Server(object): +class Server(IRCObject.Object): def __init__(self, bot, events, id, alias, hostname, port, password, ipv4, tls, nickname, username, realname): self.connected = False diff --git a/src/IRCUser.py b/src/IRCUser.py index 1b2fdbdc..93554e16 100644 --- a/src/IRCUser.py +++ b/src/IRCUser.py @@ -1,7 +1,7 @@ import uuid -from . import IRCBuffer, Utils +from . import IRCBuffer, IRCObject, Utils -class User(object): +class User(IRCObject.Object): def __init__(self, nickname, id, server, bot): self.server = server self.set_nickname(nickname) @@ -22,6 +22,8 @@ class User(object): def __repr__(self): return "IRCUser.User(%s|%s)" % (self.server.name, self.name) + def __str__(self): + return self.nickname def get_id(self): return (self.identified_account_id_override or