3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 20:22:45 +01:00
PyLink/plugins/commands.py

48 lines
1.6 KiB
Python
Raw Normal View History

# commands.py: base PyLink commands
2015-05-31 07:35:00 +02:00
import sys
import os
import logging
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import utils
from conf import conf
2015-07-05 22:44:48 +02:00
from log import log
@utils.add_cmd
def debug(irc, source, args):
2015-07-05 22:44:48 +02:00
log.debug('user index: %s' % irc.users)
log.debug('server index: %s' % irc.servers)
log.debug('channels index: %s' % irc.channels)
utils.msg(irc, source, 'Debug info printed to console.')
@utils.add_cmd
def status(irc, source, args):
identified = irc.users[source].identified
if identified:
utils.msg(irc, source, 'You are identified as %s.' % identified)
else:
utils.msg(irc, source, 'You are not identified as anyone.')
2015-05-31 07:35:00 +02:00
@utils.add_cmd
def identify(irc, source, args):
try:
username, password = args[0], args[1]
except IndexError:
utils.msg(irc, source, 'Error: not enough arguments.')
return
if username.lower() == conf['login']['user'].lower() and password == conf['login']['password']:
realuser = conf['login']['user']
irc.users[source].identified = realuser
utils.msg(irc, source, 'Successfully logged in as %s.' % realuser)
else:
utils.msg(irc, source, 'Incorrect credentials.')
u = irc.users[source]
log.warning("(%s) Failed login to %r from user '%s!%s@%s' (UID %r).",
irc.name, username, u.nick, u.ident, u.host, u.uid)
def listcommands(irc, source, args):
cmds = list(utils.bot_commands.keys())
cmds.sort()
utils.msg(irc, source, 'Available commands include: %s' % ', '.join(cmds))
utils.add_cmd(listcommands, 'list')