Implement src/IRCObject.py to convert specific objects in to strings when
passing them to modules/scripts.py scripts
This commit is contained in:
parent
120acf54ec
commit
59243f492f
4 changed files with 13 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import glob, json, os, subprocess
|
import glob, json, os, subprocess
|
||||||
from src import Utils
|
from src import IRCObject, Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
@ -37,6 +37,8 @@ class Module(object):
|
||||||
env[key.upper()] = str(int(value))
|
env[key.upper()] = str(int(value))
|
||||||
elif isinstance(value, (list, dict)):
|
elif isinstance(value, (list, dict)):
|
||||||
env[key.upper()] = json.dumps(value)
|
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)
|
proc = subprocess.Popen([filename], stdout=subprocess.PIPE, env=env)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import uuid
|
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):
|
def __init__(self, name, id, server, bot):
|
||||||
self.name = Utils.irc_lower(server, name)
|
self.name = Utils.irc_lower(server, name)
|
||||||
self.id = id
|
self.id = id
|
||||||
|
@ -19,6 +19,8 @@ class Channel(object):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "IRCChannel.Channel(%s|%s)" % (self.server.name, self.name)
|
return "IRCChannel.Channel(%s|%s)" % (self.server.name, self.name)
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
def set_topic(self, topic):
|
def set_topic(self, topic):
|
||||||
self.topic = topic
|
self.topic = topic
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import collections, socket, ssl, sys, time
|
import collections, socket, ssl, sys, time
|
||||||
from . import IRCChannel, IRCUser, Utils
|
from . import IRCChannel, IRCObject, IRCUser, Utils
|
||||||
|
|
||||||
THROTTLE_LINES = 4
|
THROTTLE_LINES = 4
|
||||||
THROTTLE_SECONDS = 1
|
THROTTLE_SECONDS = 1
|
||||||
READ_TIMEOUT_SECONDS = 120
|
READ_TIMEOUT_SECONDS = 120
|
||||||
PING_INTERVAL_SECONDS = 30
|
PING_INTERVAL_SECONDS = 30
|
||||||
|
|
||||||
class Server(object):
|
class Server(IRCObject.Object):
|
||||||
def __init__(self, bot, events, id, alias, hostname, port, password,
|
def __init__(self, bot, events, id, alias, hostname, port, password,
|
||||||
ipv4, tls, nickname, username, realname):
|
ipv4, tls, nickname, username, realname):
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import uuid
|
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):
|
def __init__(self, nickname, id, server, bot):
|
||||||
self.server = server
|
self.server = server
|
||||||
self.set_nickname(nickname)
|
self.set_nickname(nickname)
|
||||||
|
@ -22,6 +22,8 @@ class User(object):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "IRCUser.User(%s|%s)" % (self.server.name, self.name)
|
return "IRCUser.User(%s|%s)" % (self.server.name, self.name)
|
||||||
|
def __str__(self):
|
||||||
|
return self.nickname
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return (self.identified_account_id_override or
|
return (self.identified_account_id_override or
|
||||||
|
|
Loading…
Reference in a new issue