示例#1
0
def chg_trigger(chan, nick, *args):
  if len(args[0]) != 1:
    ircsock.reply(chan, nick, '%s is too long (%d). May only be 1 character in length.' % (args[0], len(args[0])))
    return

  conf.bot['trigger'] = args[0]
  ircsock.reply(chan, nick, 'Changed command trigger to: %s' % args[0])
示例#2
0
文件: core.py 项目: miniCruzer/sucks
def modload(chan, nick, mod):
  if mod in module.modinfo:
    ircsock.reply(chan, nick, '%s is already loaded. (%s)' % (mod, module.modinfo[mod, 'version']))
    return
  try:
    module.load(mod)
  except IOError, e:
    ircsock.msg(chan, '%s: %s' (mod, e))
    return
示例#3
0
文件: core.py 项目: miniCruzer/sucks
def help(chan, nick, args = ''):
  args = args.split()
  if len(args) < 1:
    all = ' '.join(event.cmdnames)
    ircsock.reply(chan, nick, 'COMMANDS: %s' % all)
  else:
    if args[0] not in event.commands:
      ircsock.reply(chan, nick, '\002%s\002: Not found.' % args[0])
    else:
      ircsock.reply(chan, nick, '\002%s\002: %s' % (args[0].upper(), event.commands[args[0], 'help']))
示例#4
0
def cmd_lookup(src):

  user = src[0]
  user = user[1:]
  user = user.split('!')
  user = user[0]

  target = src[2]

  src.pop(0)
  src.pop(0)
  src.pop(0)
  msg = ' '.join(src)
  msg = msg[1:]
  if msg.startswith(conf.bot['trigger']): 
    trigger = conf.bot['trigger']
    msg = msg[1:]
    cmd = msg.split(' ')
    cmd = cmd[0]
    cmd = cmd.lower()

    if msg:
      args = msg.split()
      args.pop(0)
      args = ' '.join(args)
    if cmd in event.commands:
      code = event.commands[cmd, 'code']
      try:
        if args: code(target, user, args)
        if not args: code(target, user)
      except TypeError, e:
        ircsock.reply(target, user, '-%s failed: %s' % (cmd, e))
        if (cmd, 'syntax') in event.commands:
          ircsock.msg(target, 'Syntax: %s%s %s' % (conf.bot['trigger'], cmd.upper(), event.commands[cmd, 'syntax']))
          return
        else:
          ircsock.reply(target, user, 'See HELP %s for useage.' % cmd)
          return
    else:
      ircsock.reply(target, user, '%s: Command not found.' % cmd.upper())
示例#5
0
文件: core.py 项目: miniCruzer/sucks
def modunload(chan, nick, mod):
  if mod not in module.modinfo:
    ircsock.reply(chan, nick, '\002%s\002 is not loaded.' % mod)
  else:
    del module.modinfo[mod]
    ircsock.reply(chan, nick, '\002%s\002 - Unloaded.' % mod)
示例#6
0
文件: core.py 项目: miniCruzer/sucks
  'pkg': __name__
})

def modload(chan, nick, mod):
  if mod in module.modinfo:
    ircsock.reply(chan, nick, '%s is already loaded. (%s)' % (mod, module.modinfo[mod, 'version']))
    return
  try:
    module.load(mod)
  except IOError, e:
    ircsock.msg(chan, '%s: %s' (mod, e))
    return
  except:
    ircsock.msg(chan, '%s: %s' % (mod, sys.exc_info()))
    return
  ircsock.reply(chan, nick, '%s loaded.' % mod)

event.command_add({
  'cmd': 'modload',
  'help': 'Load a module runtime. Module is in relation to the root directory of the bot.',
  'syntax': '<module>.py',
  'acl': 'owner',
  'code': modload,
  'pkg': __name__
})

def modunload(chan, nick, mod):
  if mod not in module.modinfo:
    ircsock.reply(chan, nick, '\002%s\002 is not loaded.' % mod)
  else:
    del module.modinfo[mod]