mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-12 05:02:33 +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
|
import proto
|
||||||
|
|
||||||
@proto.add_cmd
|
@proto.add_cmd
|
||||||
def hello(irc, source, command, args):
|
def hello(irc, source, args):
|
||||||
proto._sendFromUser(irc, 'PRIVMSG %s :hello!' % source)
|
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])
|
_sendFromServer(irc, 'PONG %s' % args[1])
|
||||||
|
|
||||||
def handle_privmsg(irc, source, command, args):
|
def handle_privmsg(irc, source, command, args):
|
||||||
# _sendFromUser(irc, 'PRIVMSG %s :hello!' % numeric)
|
|
||||||
print(irc.users)
|
|
||||||
prefix = irc.conf['bot']['prefix']
|
prefix = irc.conf['bot']['prefix']
|
||||||
if args[0] == irc.pseudoclient.uid:
|
if args[0] == irc.pseudoclient.uid:
|
||||||
cmd_args = args[1].split(' ', 1)
|
cmd_args = args[1].split(' ')
|
||||||
cmd = cmd_args[0]
|
cmd = cmd_args[0]
|
||||||
try:
|
try:
|
||||||
cmd_args = cmd_args[1]
|
cmd_args = cmd_args[1:]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
cmd_args = []
|
cmd_args = []
|
||||||
try:
|
try:
|
||||||
bot_commands[cmd](irc, source, command, args)
|
bot_commands[cmd](irc, source, cmd_args)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
_sendFromUser(irc, 'PRIVMSG %s :unknown command %r' % (source, cmd))
|
_sendFromUser(irc, 'PRIVMSG %s :unknown command %r' % (source, cmd))
|
||||||
|
|
||||||
@ -161,7 +159,6 @@ def handle_events(irc, data):
|
|||||||
numeric = args[0]
|
numeric = args[0]
|
||||||
command = args[1]
|
command = args[1]
|
||||||
args = args[2:]
|
args = args[2:]
|
||||||
print(args)
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user