mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-11 20:52:42 +01:00
cleanup, add commands.py plugin (incomplete)
This commit is contained in:
parent
53505084b5
commit
6b79793336
16
plugins/commands.py
Normal file
16
plugins/commands.py
Normal file
@ -0,0 +1,16 @@
|
||||
# commands.py: base PyLink commands
|
||||
import sys, os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import proto
|
||||
|
||||
@proto.add_cmd
|
||||
def tell(irc, source, args):
|
||||
try:
|
||||
target, text = args[0], ' '.join(args[1:])
|
||||
except IndexError:
|
||||
proto._sendFromUser(irc, 'PRIVMSG %s :Error: not enough arguments' % source)
|
||||
return
|
||||
try:
|
||||
proto._sendFromUser(irc, 'NOTICE %s :%s' % (irc.users[target].uid, text))
|
||||
except KeyError:
|
||||
proto._sendFromUser(irc, 'PRIVMSG %s :unknown user %r' % (source, target))
|
@ -3,5 +3,5 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import proto
|
||||
|
||||
@proto.add_cmd
|
||||
def hello(irc, source, command, args):
|
||||
def hello(irc, source, args):
|
||||
proto._sendFromUser(irc, 'PRIVMSG %s :hello!' % source)
|
||||
|
9
proto.py
9
proto.py
@ -78,18 +78,16 @@ def handle_ping(irc, servernumeric, command, args):
|
||||
_sendFromServer(irc, 'PONG %s' % args[1])
|
||||
|
||||
def handle_privmsg(irc, source, command, args):
|
||||
# _sendFromUser(irc, 'PRIVMSG %s :hello!' % numeric)
|
||||
print(irc.users)
|
||||
prefix = irc.conf['bot']['prefix']
|
||||
if args[0] == irc.pseudoclient.uid:
|
||||
cmd_args = args[1].split(' ', 1)
|
||||
cmd_args = args[1].split(' ')
|
||||
cmd = cmd_args[0]
|
||||
try:
|
||||
cmd_args = cmd_args[1]
|
||||
cmd_args = cmd_args[1:]
|
||||
except IndexError:
|
||||
cmd_args = []
|
||||
try:
|
||||
bot_commands[cmd](irc, source, command, args)
|
||||
bot_commands[cmd](irc, source, cmd_args)
|
||||
except KeyError:
|
||||
_sendFromUser(irc, 'PRIVMSG %s :unknown command %r' % (source, cmd))
|
||||
|
||||
@ -161,7 +159,6 @@ def handle_events(irc, data):
|
||||
numeric = args[0]
|
||||
command = args[1]
|
||||
args = args[2:]
|
||||
print(args)
|
||||
except IndexError:
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user