mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Committed partial Configurable implementation (gotta go back home and hack on it more later).
This commit is contained in:
parent
7d5a7bf7f0
commit
9b6dce4961
@ -33,10 +33,12 @@ import fix
|
|||||||
|
|
||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import sets
|
import sets
|
||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
|
import random
|
||||||
import urllib2
|
import urllib2
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
@ -50,8 +52,6 @@ import ircdb
|
|||||||
import ircutils
|
import ircutils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
import re
|
|
||||||
import random
|
|
||||||
|
|
||||||
__all__ = ['ChannelDBHandler', 'PeriodicFileDownloader', 'ToggleDictionary']
|
__all__ = ['ChannelDBHandler', 'PeriodicFileDownloader', 'ToggleDictionary']
|
||||||
|
|
||||||
@ -197,6 +197,50 @@ class PeriodicFileDownloader(object):
|
|||||||
world.threadsSpawned += 1
|
world.threadsSpawned += 1
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigurableDictionary(object):
|
||||||
|
"""This is a dictionary to handle configuration for individual channels,
|
||||||
|
including a default configuration for channels that haven't modified their
|
||||||
|
configuration from the default.
|
||||||
|
"""
|
||||||
|
def __init__(self, seq):
|
||||||
|
self.helps = {}
|
||||||
|
self.types = {}
|
||||||
|
self.channels = {None: {}}
|
||||||
|
for (name, type, default, help) in seq:
|
||||||
|
self.helps[name] = help
|
||||||
|
self.types[name] = type
|
||||||
|
self.channels[None][name] = default
|
||||||
|
|
||||||
|
def get(self, name, channel=None):
|
||||||
|
return self.channels[channel][name]
|
||||||
|
|
||||||
|
def set(self, name, value, channel=None):
|
||||||
|
self.channels[channel][name] = self.types[value]
|
||||||
|
|
||||||
|
# XXX: Make persistent.
|
||||||
|
|
||||||
|
class Configurable(object):
|
||||||
|
"""A mixin class to provide a "config" command that can be consistent
|
||||||
|
across all plugins, in order to unify the configuration for each plugin.
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self.configurables = ConfigurableDictionary(self.configurables)
|
||||||
|
s =
|
||||||
|
|
||||||
|
def config(self, irc, msg, args):
|
||||||
|
"""[<channel>] <name> [<value>]
|
||||||
|
|
||||||
|
Sets the config variable <name> to <value> on <channel>. If <value>
|
||||||
|
isn't given, returns the current value of <name> on <channel>.
|
||||||
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
|
itself.
|
||||||
|
"""
|
||||||
|
channel = privmsgs.getChannel(msg, args)
|
||||||
|
(name, value) = privmsgs.getArgs(args, needed=0, optional=2)
|
||||||
|
if not name:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ToggleDictionary(object):
|
class ToggleDictionary(object):
|
||||||
"""I am ToggleDictionary! Hear me roar!
|
"""I am ToggleDictionary! Hear me roar!
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user