예제 #1
0
def add_plugin(plugin_name):
    if plugin_name in config['plugins']:
        return "This plugin is already active"
    if not exists(join(WD, "plugins", plugin_name + ".py")):
        return "There is no file that name is " + plugin_name + " in plugins directory"
    config['plugins'].append(plugin_name)
    save_config()
    load_plugins()
    return "Plugin " + plugin_name + " Enable Successfully"
예제 #2
0
def remove_plugin(plugin_name):
    if plugin_name == "plugins":
        return "You Can not disable plugins plugin !! :|"
    if plugin_name not in config['plugins']:
        return "This plugin is not active"
    config['plugins'].remove(plugin_name)
    save_config()
    load_plugins()
    return "Plugin " + plugin_name + " Disable Successfully"
예제 #3
0
def remove_plugin(plugin_name):
    if plugin_name == "plugins":
        return "You Can not disable plugins plugin !! :|"
    if plugin_name not in config['plugins']:
        return "This plugin is not active"
    config['plugins'].remove(plugin_name)
    save_config()
    load_plugins()
    return "Plugin " + plugin_name + " Disable Successfully"
예제 #4
0
def add_plugin(plugin_name):
    if plugin_name in config['plugins']:
        return "This plugin is already active"
    if not exists(join(WD, "plugins", plugin_name + ".py")):
        return "There is no file that name is " + plugin_name + " in plugins directory"
    config['plugins'].append(plugin_name)
    save_config()
    load_plugins()
    return "Plugin " + plugin_name + " Enable Successfully"
예제 #5
0
    def makeService(self, options):
        with open(options.config, "r") as config_file:
            config = json.load(config_file)

        root = resource.Resource()
        root.putChild("jsMath", static.File(config["global"]["jsmath"]))

        bot = service.MultiService()
        xmppclient = XMPPClient(JID(config["global"]["jid"]), config["global"]["password"])
        xmppclient.logTraffic = options["verbose"]
        xmppclient.setServiceParent(bot)
        xmppclient.rooms = dict()

        xmlrpc_port = config["global"].get("xml-rpc-port", None)
        if xmlrpc_port is not None:
            xmlrpcinterface = XMLRPCInterface(xmppclient)
            rpc = internet.TCPServer(xmlrpc_port, server.Site(xmlrpcinterface))
            rpc.setName("XML-RPC")
            rpc.setServiceParent(bot)

        for muc_config in config["mucs"]:
            room_jid = JID(muc_config["jid"])
            mucbot = KITBot(room_jid, muc_config.get("password", None), config["global"]["logpath"])
            mucbot.setHandlerParent(xmppclient)

            if "xml-rpc-id" in muc_config:
                xmppclient.rooms[muc_config["xml-rpc-id"]] = mucbot

            # Log resource
            portal = Portal(
                LogViewRealm(os.path.join(config["global"]["logpath"], room_jid.user + ".log")),
                [strcred.makeChecker(muc_config["log-auth"])],
            )
            credential_factory = DigestCredentialFactory("md5", "Hello Kitty!")
            auth_resource = HTTPAuthSessionWrapper(portal, [credential_factory])
            root.putChild(room_jid.user, auth_resource)

        httpd_log_view = internet.TCPServer(config["global"]["http-port"], server.Site(root))
        httpd_log_view.setServiceParent(bot)

        # REPL over SSH
        def makeREPLProtocol():
            namespace = dict(bot=xmppclient)
            return insults.ServerProtocol(manhole.ColoredManhole, namespace)

        repl_realm = manhole_ssh.TerminalRealm()
        repl_realm.chainedProtocolFactory = makeREPLProtocol
        repl_checker = checkers.SSHPublicKeyDatabase()
        repl_portal = Portal(repl_realm, [repl_checker])
        repl_factory = manhole_ssh.ConchFactory(repl_portal)
        repl = internet.TCPServer(config["global"]["ssh-port"], repl_factory)
        repl.setServiceParent(bot)

        load_plugins(config)

        return bot
예제 #6
0
def add_plugin(plugin_name):
    if plugin_name in bot.config['plugins']:
        return "This plugin is already active"
    if not exists(join(bot.WD, "plugins", plugin_name + ".py")):
        return "There is no file with name " + plugin_name + " in plugins directory"
    bot.config['plugins'].append(plugin_name)
    bot.save_config()
    bot.load_plugins()
    text = plugin_name + " enabled"
    return text
예제 #7
0
def remove_plugin(plugin_name):
    if plugin_name == "admins":
        bot.load_plugins()
        return "You can't disable plugins admin!\nPlugins reloaded."
    if plugin_name not in bot.config['plugins']:
        return "This plugin is not active"
    bot.config['plugins'].remove(plugin_name)
    bot.save_config()
    bot.load_plugins()
    text = plugin_name + " disabled"
    return text
예제 #8
0
def run(message, matches, convo_id, chat_data, user_data):
    # msg_type, convo_id, user_id = glance(message)
    if matches[0] == 'plugins':
        if len(matches) == 1:
            res = show_plugins()
            return bot.send_message(convo_id, res)
        if matches[1] == 'reload':
            bot.load_plugins()
            return bot.send_message(convo_id, 'Plugins has been reloaded')
        if matches[1] == 'enable':
            plugin_name = matches[2]
            bot.send_message(convo_id, add_plugin(plugin_name))
            return bot.send_message(convo_id, show_plugins())
        if matches[1] == 'disable':
            plugin_name = matches[2]
            bot.send_message(convo_id, remove_plugin(plugin_name))
            return bot.send_message(convo_id, show_plugins())
예제 #9
0
def reload_plugin():
    load_plugins()
    return "Plugins Reloaded !"
예제 #10
0
def reload_plugin():
    load_plugins()
    return "Plugins Reloaded !"
예제 #11
0
def setlang(lang):
    config['lang'] = lang
    save_config()
    load_plugins()
    return "Lang set " + lang
예제 #12
0
파일: app.py 프로젝트: shellvon/tdd
    level=logging.DEBUG,
    format=
    '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
    datefmt='%H:%M:%S')


def create_app(config_file):
    app = Flask(__name__)
    app.config.from_object(config_file)
    return app


app = create_app('setting')

bot = AI(setting.TENCENT_AI_APP_ID, setting.TENCENT_AI_APP_KEY,
         load_plugins(plugins))


def tuling_bot(bot):
    from hashlib import md5
    from tuling import API
    http = API(setting.TULING_API_KEY)

    def tuling_chat_command(message):
        bot.cache.set(message.source, 'TDD')  # 别过期.
        user_id = md5(message.source).hexdigest()
        if message.type != 'text':
            return u'仅支持纯文字聊天[当前模式为TDD聊天,您可以尝试输入Exit退出之后执行其他命令]'

        if message.content.lower() == 't' or message.content.lower() == 'tdd':
            return u'Hello,我是淘逗逗的姐姐^_^, 谢谢你把我召唤出来~你不让我exit我是不会退的哦~'