示例#1
0
    def reload_modules(self, server, message, module):
        # Find and remove all callbacks
        removed = self.remove_modules(server, module)
        reloaded = []

        if removed:
            for i in removed:
                mod = i.module
                if mod.__name__ in reloaded: 
                    continue
                if "__destroy__" in dir(mod):
                    mod.__destroy__()
                imp.reload(mod)
                server.loadplugin(mod)
                reloaded.append(mod.__name__)
            if len(reloaded) == 1:
                yield "12Module Manager│ %s reloaded." % (reloaded[0])
            else:
                table = namedtable(reloaded,
                                   size=72,
                                   header="Reloaded modules ")
                for i in table:
                    yield i
        else:
            yield "05Module Manager│ Module not found."
示例#2
0
    def reload_modules(self, server, message, module):
        # Find and remove all callbacks
        removed = self.remove_modules(server, module)
        reloaded = []

        if removed:
            for i in removed:
                mod = i.module
                if mod.__name__ in reloaded:
                    continue
                if "__destroy__" in dir(mod):
                    mod.__destroy__()
                imp.reload(mod)
                server.loadplugin(mod)
                reloaded.append(mod.__name__)
            if len(reloaded) == 1:
                yield "12│ 🔌 │ %s reloaded." % (reloaded[0])
            else:
                table = namedtable(reloaded,
                                   size=72,
                                   header="Reloaded modules ")
                for i in table:
                    yield i
        else:
            yield "05│ 🔌 │ Module not found."
示例#3
0
 def list_disabled(self, server, message):
     blacklisted = server.blacklist.get(server.lower(message.context), [])
     if blacklisted:
         table = namedtable(blacklisted, size=72, header="Disabled modules ")
         for i in table:
             yield i
     else:
         yield "12│ 🔌 │ Blacklist is empty."
示例#4
0
 def unregister_modules(self, server, message, module):
     removed = {x.module.__name__ for x in self.remove_modules(server, module)}
     if not removed:
         yield "05│ 🔌 │ Module not found."
     elif len(removed) == 1:
         yield "12│ 🔌 │ %s unloaded." % (list(removed)[0])
     else:
         table = namedtable(removed, size=72, header="Unregistered modules ")
         for i in table:
             yield i
示例#5
0
 def list_disabled(self, server, message):
     blacklisted = server.blacklist.get(server.lower(message.context), [])
     if blacklisted:
         table = namedtable(blacklisted,
                            size=72,
                            header="Disabled modules ")
         for i in table:
             yield i
     else:
         yield "12│ 🔌 │ Blacklist is empty."
示例#6
0
 def list_modules(self, server, message, mask):
     modules = set()
     for ls in server.callbacks.values():
         modules |= {i.module.__name__ for i in ls if i.module}
     table = namedtable(
         [i.split(".")[-1] for i in modules if i.startswith(mask)]
         or ["No matches."],
         size=72,
         header="Loaded modules ")
     for i in table:
         yield i
示例#7
0
 def unregister_modules(self, server, message, module):
     removed = {
         x.module.__name__
         for x in self.remove_modules(server, module)
     }
     if not removed:
         yield "05│ 🔌 │ Module not found."
     elif len(removed) == 1:
         yield "12│ 🔌 │ %s unloaded." % (list(removed)[0])
     else:
         table = namedtable(removed,
                            size=72,
                            header="Unregistered modules ")
         for i in table:
             yield i
示例#8
0
def complete_trigger(server, message, query):
    """
    - Syntax: [!@](complete|suggest) 03query
    - Description: Ask Google for similar search queries.
    """
    result = suggest(query)
    q = query.lower().strip().strip("\"'")

    if result:
        if message.prefix == ".":
            parsed = []
            for i in result:
                if i.startswith(q):
                    i = i.replace(
                        q, "" if i.startswith(q) else "\x0315%s\x03" % q,
                        1).rstrip()
                    if not i.startswith(" "):
                        i = "\x0315%s\x03%s" % (q, i)
                    else:
                        i = i.strip()
                else:
                    i = i.replace(q, "\x0315%s\x03" % q)
                parsed.append(i)
            line = parsed.pop(0)
            while parsed and striplen(line + parsed[0]) + 3 < 60:
                line += " \x0312·\x03 " + parsed.pop(0)
            yield "12│ %s 12│ %s" % (query, line)
        else:
            result = [i.replace(q, "\x0315%s\x03" % q) for i in result]
            table = namedtable(
                result,
                size=72,
                rowmax=4 if message.text.startswith("@") else None,
                header="12G04o08o12g03l04e12 suggest  ",
                rheader="'%s'" % query)
            for line in table:
                yield line
    else:
        yield "05Google suggest│  No results."