def run(app: Client, msg: Message): config = ConfigParser(interpolation=ExtendedInterpolation()) config.read(join(rp, 'data', 'config.ini')) if search(r"^([!#/])?plg \+ (.+)$", msg.text): plugin_name = search(r"([!#/])?plg \+ (.+)", msg.text).group(2).strip() if plugin_name in config.options('Plugins'): config.set('Plugins', plugin_name, 'enabled') app.send_message(msg.chat.id, '**Plugin {} Has Been Enabled!**'.format(plugin_name), parse_mode='markdown') with open(join(rp, 'data', 'config.ini'), 'w') as file: config.write(file) reload() else: app.send_message(msg.chat.id, '**This Plugin Doesnt Exists.!**', parse_mode='markdown') elif search(r"^([!#/])?plg - (.+)$", msg.text): plugin_name = search(r"([!#/])?plg - (.+)", msg.text).group(2).strip() if plugin_name in config.options('Plugins'): config.set('Plugins', plugin_name, 'disabled') app.send_message(msg.chat.id, '**Plugin {} Has Been Disabled!**'.format(plugin_name), parse_mode='markdown') with open(join(rp, 'data', 'config.ini'), 'w') as file: config.write(file) reload() else: app.send_message(msg.chat.id, '**This Plugin Doesnt Exists.!**', parse_mode='markdown') elif search('^([!?#])?reload$', msg.text.lower()): app.send_message(msg.chat.id, '**Bot Reloaded!**', parse_mode='markdown') reload() elif search('^[!#/]?plugins$', msg.text.lower()): text = '' for plug in config['Plugins']: text += '\n`{0}` => **{1}**'.format(plug, config.get('Plugins', plug)) try: app.send_message(msg.chat.id, text, parse_mode='markdown', reply_to_message_id=msg.message_id) except: pass
# -*- coding: utf-8 -*- import bot import time import re from lib import timeutils, utils bot.reload(timeutils) bot.reload(utils) class RedFlare: def __init__(self, url, http, timeout=5): j = http.request(url, timeout=timeout).json() self.time = time.time() self.servers = [] self.players = [] self.playerauths = [] for serverkey in j: server = j[serverkey] serverdata = { 'id': serverkey, 'host': server['host'], 'port': server['port'], 'mode': server['gameMode'], 'mutators': server['mutators'], 'time': server['timeLeft'], 'map': server['mapName'], 'version': server['gameVersion'], 'description': server['description'], 'players': [], 'playerauths': [],
# -*- coding: utf-8 -*- import bot import lib.alias bot.reload(lib.alias) class M_Alias(lib.alias.Module): def register(self): lib.alias.Module.register(self) self.addcommand( self.get, "get", "Get an alias.", ["alias"]) self.addcommand( self.add, "add", "Add an alias.", ["alias", "content..."], quote=False) self.addcommand( self.remove, "remove", "Remove an alias.", ["alias"],) self.addcommand(
# -*- coding: utf-8 -*- import bot from lib import utils bot.reload(utils) def pms(p, m): if m: return "%s/%s" % (p, m) return p class M_Loader(bot.Module): index = "loader" def register(self): self.addcommand( self.load, "load", "Load a plugin(/module), requires admin.", ["[-temp]", "plugin"]) self.addcommand( self.unload, "unload", "Unload a plugin(/module), requires admin.", ["[-temp]", "plugin"]) self.addcommand(
# -*- coding: utf-8 -*- import bot from . import loader, help, list, echo, net from . import versions, settings, more, vepy, logger [bot.reload(x) for x in [loader, help, list, net, echo, versions, settings, more, vepy, logger]]
# -*- coding: utf-8 -*- # Various utility commands. import bot from . import calc, lookup [bot.reload(x) for x in [calc, lookup]]
# -*- coding: utf-8 -*- # Red Eclipse (http://redeclipse.net) support. import bot from . import REirc, redflare, restatsdb [bot.reload(x) for x in [REirc, redflare, restatsdb]]
# -*- coding: utf-8 -*- import bot import lib.config bot.reload(lib.config) class M_Config(lib.config.Module): ignore = [] def register(self): lib.config.Module.register(self) bot.register.module(M_Config)
# -*- coding: utf-8 -*- import bot import lib.rights bot.reload(lib.rights) class M_Rights(lib.rights.Module): def register(self): lib.rights.Module.register(self) def _rights(self, idstring, context): """Rights from a context.""" rights = [] matches = [] return rights, matches bot.register.module(M_Rights)
# -*- coding: utf-8 -*- import bot import time from . import ailib bot.reload(ailib) class Module(bot.Module): index = "chatbot" def register(self): self.lastphrase = {} self.lasttime = {} if self.server.index in ['irc']: self.server.rget('addchannelrights')({ 'chatbot': ['op'], }) self.addsetting('#globaldb', True) self.addcommand(self.chat, "chat", "Talk to the bot.", ["text..."]) self.addcommandalias('chat', 'c') self.server.addrights({ 'chatbot': ['admin'], }) def chat(self, context, args): if self.server.index in ['irc']: if context.channel and not self.getchannelsetting( 'globaldb', context): context.exceptchannelrights(['chatbot']) else:
# -*- coding: utf-8 -*- # Internet utility commands. import bot from . import ip, url [bot.reload(x) for x in [ip, url]]