示例#1
0
        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())
       
event.hook_add({
  'pkg': 'src/interface.py',
  'event': 'PRIVMSG',
  'code': cmd_lookup
})

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])

event.command_add({
  'pkg': 'src/interface.py',
  'cmd': 'trigger',
  'help': 'Change the command prefix trigger.',
  'syntax': '<trigger>',
  'code': chg_trigger
})
示例#2
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']))

event.command_add({
  'cmd': 'help',
  'syntax': '<command>',
  'help': 'View all loaded commands.',
  'code': help,
  'pkg': __name__
})

def evalirc(chan, nick, expr):
  try:
    result = eval(expr)
  except:
    reply(chan, nick, '%s raised exception: %s' % (expr, sys.exc_info()))
    return
  if result is None:
    reply(chan, nick, '%s is None.' % expr)
    return

  ircsock.msg(chan, result)