mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Updated to use commands.wrap.
This commit is contained in:
parent
98c716d8cb
commit
e24c1c0cc6
@ -46,11 +46,11 @@ from itertools import imap, ifilter
|
|||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.irclib as irclib
|
import supybot.irclib as irclib
|
||||||
import supybot.drivers as drivers
|
import supybot.drivers as drivers
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
from supybot.structures import RingBuffer
|
from supybot.structures import RingBuffer
|
||||||
@ -146,45 +146,38 @@ class Relay(callbacks.Privmsg):
|
|||||||
irc.queueMsg(ircmsgs.who(channel))
|
irc.queueMsg(ircmsgs.who(channel))
|
||||||
irc.queueMsg(ircmsgs.names(channel))
|
irc.queueMsg(ircmsgs.names(channel))
|
||||||
|
|
||||||
def join(self, irc, msg, args):
|
def join(self, irc, msg, args, channel):
|
||||||
"""<channel>
|
"""[<channel>]
|
||||||
|
|
||||||
Starts relaying between the channel <channel> on all networks. If on a
|
Starts relaying between the channel <channel> on all networks. If on a
|
||||||
network the bot isn't in <channel>, he'll join. This commands is
|
network the bot isn't in <channel>, he'll join. This commands is
|
||||||
required even if the bot is in the channel on both networks; he won't
|
required even if the bot is in the channel on both networks; he won't
|
||||||
relay between those channels unless he's told to join both
|
relay between those channels unless he's told to join both
|
||||||
channels.
|
channels. If <channel> is not given, starts relaying on the channel
|
||||||
|
the message was sent in.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getArgs(args)
|
|
||||||
if not ircutils.isChannel(channel):
|
|
||||||
irc.error('%r is not a valid channel.' % channel)
|
|
||||||
return
|
|
||||||
self.registryValue('channels').add(channel)
|
self.registryValue('channels').add(channel)
|
||||||
for otherIrc in world.ircs: # Should we abstract this?
|
for otherIrc in world.ircs: # Should we abstract this?
|
||||||
if channel not in otherIrc.state.channels:
|
if channel not in otherIrc.state.channels:
|
||||||
otherIrc.queueMsg(ircmsgs.join(channel))
|
otherIrc.queueMsg(ircmsgs.join(channel))
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
join = privmsgs.checkCapability(join, 'owner')
|
join = wrap(join, ['channel'])
|
||||||
|
|
||||||
def part(self, irc, msg, args):
|
def part(self, irc, msg, args, channel):
|
||||||
"""<channel>
|
"""<channel>
|
||||||
|
|
||||||
Ceases relaying between the channel <channel> on all networks. The bot
|
Ceases relaying between the channel <channel> on all networks. The bot
|
||||||
will part from the channel on all networks in which it is on the
|
will part from the channel on all networks in which it is on the
|
||||||
channel.
|
channel.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getArgs(args)
|
self.registryValue('channels').discard(channel)
|
||||||
if not ircutils.isChannel(channel):
|
|
||||||
irc.error('%r is not a valid channel.' % channel)
|
|
||||||
return
|
|
||||||
self.registryValue('channels').remove(channel)
|
|
||||||
for otherIrc in world.ircs:
|
for otherIrc in world.ircs:
|
||||||
if channel in otherIrc.state.channels:
|
if channel in otherIrc.state.channels:
|
||||||
otherIrc.queueMsg(ircmsgs.part(channel))
|
otherIrc.queueMsg(ircmsgs.part(channel))
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
part = privmsgs.checkCapability(part, 'owner')
|
part = wrap(part, ['channel'])
|
||||||
|
|
||||||
def nicks(self, irc, msg, args):
|
def nicks(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
|
|
||||||
Returns the nicks of the people in the channel on the various networks
|
Returns the nicks of the people in the channel on the various networks
|
||||||
@ -192,7 +185,6 @@ class Relay(callbacks.Privmsg):
|
|||||||
isn't sent on the channel itself.
|
isn't sent on the channel itself.
|
||||||
"""
|
"""
|
||||||
realIrc = self._getRealIrc(irc)
|
realIrc = self._getRealIrc(irc)
|
||||||
channel = privmsgs.getChannel(msg, args)
|
|
||||||
if channel not in self.registryValue('channels'):
|
if channel not in self.registryValue('channels'):
|
||||||
irc.error('I\'m not relaying in %s.' % channel)
|
irc.error('I\'m not relaying in %s.' % channel)
|
||||||
return
|
return
|
||||||
@ -234,15 +226,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
(ircutils.bold(network), numUsers, usersS))
|
(ircutils.bold(network), numUsers, usersS))
|
||||||
users.sort()
|
users.sort()
|
||||||
irc.reply('; '.join(users))
|
irc.reply('; '.join(users))
|
||||||
|
nicks = wrap(nicks, ['channel'])
|
||||||
def ignore(self, irc, msg, args):
|
|
||||||
"""[<channel>] <nick|hostmask>
|
|
||||||
|
|
||||||
Ignores everything said or done by <nick|hostmask> in <channel>.
|
|
||||||
<channel> is only necessary if the message isn't sent in the channel
|
|
||||||
itself.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def do311(self, irc, msg):
|
def do311(self, irc, msg):
|
||||||
irc = self._getRealIrc(irc)
|
irc = self._getRealIrc(irc)
|
||||||
|
@ -44,6 +44,7 @@ import time
|
|||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
import supybot.schedule as schedule
|
import supybot.schedule as schedule
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
@ -63,7 +64,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
self.Proxy(irc.irc, msg, tokens)
|
self.Proxy(irc.irc, msg, tokens)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args, seconds, command):
|
||||||
"""<seconds> <command>
|
"""<seconds> <command>
|
||||||
|
|
||||||
Schedules the command string <command> to run <seconds> seconds in the
|
Schedules the command string <command> to run <seconds> seconds in the
|
||||||
@ -72,25 +73,18 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
command was given in (with no prefixed nick, a consequence of using
|
command was given in (with no prefixed nick, a consequence of using
|
||||||
echo). Do pay attention to the quotes in that example.
|
echo). Do pay attention to the quotes in that example.
|
||||||
"""
|
"""
|
||||||
(seconds, command) = privmsgs.getArgs(args, required=2)
|
|
||||||
try:
|
|
||||||
seconds = int(seconds)
|
|
||||||
except ValueError:
|
|
||||||
irc.error('Invalid seconds value: %r' % seconds)
|
|
||||||
return
|
|
||||||
f = self._makeCommandFunction(irc, msg, command)
|
f = self._makeCommandFunction(irc, msg, command)
|
||||||
id = schedule.addEvent(f, time.time() + seconds)
|
id = schedule.addEvent(f, time.time() + seconds)
|
||||||
f.eventId = id
|
f.eventId = id
|
||||||
self.events[str(id)] = command
|
self.events[str(id)] = command
|
||||||
irc.replySuccess('Event #%s added.' % id)
|
irc.replySuccess('Event #%s added.' % id)
|
||||||
|
add = wrap(add, ['positiveInt', 'text'])
|
||||||
|
|
||||||
def remove(self, irc, msg, args):
|
def remove(self, irc, msg, args, id):
|
||||||
"""<id>
|
"""<id>
|
||||||
|
|
||||||
Removes the event scheduled with id <id> from the schedule.
|
Removes the event scheduled with id <id> from the schedule.
|
||||||
"""
|
"""
|
||||||
id = privmsgs.getArgs(args)
|
|
||||||
id = id.lower()
|
|
||||||
if id in self.events:
|
if id in self.events:
|
||||||
del self.events[id]
|
del self.events[id]
|
||||||
try:
|
try:
|
||||||
@ -104,8 +98,9 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
irc.error('Invalid event id.')
|
irc.error('Invalid event id.')
|
||||||
else:
|
else:
|
||||||
irc.error('Invalid event id.')
|
irc.error('Invalid event id.')
|
||||||
|
remove = wrap(remove, ['lowered'])
|
||||||
|
|
||||||
def repeat(self, irc, msg, args):
|
def repeat(self, irc, msg, args, name, seconds, command):
|
||||||
"""<name> <seconds> <command>
|
"""<name> <seconds> <command>
|
||||||
|
|
||||||
Schedules the command <command> to run every <seconds> seconds,
|
Schedules the command <command> to run every <seconds> seconds,
|
||||||
@ -113,19 +108,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
thereafter). <name> is a name by which the command can be
|
thereafter). <name> is a name by which the command can be
|
||||||
unscheduled.
|
unscheduled.
|
||||||
"""
|
"""
|
||||||
(name, seconds, command) = privmsgs.getArgs(args, required=3)
|
name = name.lower() # XXX We should have a "compose" context for this.
|
||||||
name = name.lower()
|
|
||||||
try:
|
|
||||||
seconds = int(seconds)
|
|
||||||
except ValueError:
|
|
||||||
irc.error('Invalid seconds: %r' % seconds)
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
name = int(name)
|
|
||||||
irc.error('Names must not be an integer.')
|
|
||||||
return
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
self.events[name] = command
|
self.events[name] = command
|
||||||
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
f = self._makeCommandFunction(irc, msg, command, remove=False)
|
||||||
id = schedule.addPeriodicEvent(f, seconds, name)
|
id = schedule.addPeriodicEvent(f, seconds, name)
|
||||||
@ -133,6 +116,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
# We don't reply because the command runs immediately.
|
# We don't reply because the command runs immediately.
|
||||||
# But should we? What if the command doesn't have visible output?
|
# But should we? What if the command doesn't have visible output?
|
||||||
# irc.replySuccess()
|
# irc.replySuccess()
|
||||||
|
repeat = wrap(repeat, ['nonInt', 'positiveInt', 'text'])
|
||||||
|
|
||||||
def list(self, irc, msg, args):
|
def list(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
@ -147,6 +131,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
else:
|
else:
|
||||||
irc.reply('There are currently no scheduled commands.')
|
irc.reply('There are currently no scheduled commands.')
|
||||||
|
list = wrap(list)
|
||||||
|
|
||||||
|
|
||||||
Class = Scheduler
|
Class = Scheduler
|
||||||
|
@ -51,10 +51,10 @@ import supybot.conf as conf
|
|||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
@ -130,15 +130,13 @@ class Seen(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass # Not in the database.
|
pass # Not in the database.
|
||||||
|
|
||||||
def seen(self, irc, msg, args):
|
def seen(self, irc, msg, args, channel, name):
|
||||||
"""[<channel>] <nick>
|
"""[<channel>] <nick>
|
||||||
|
|
||||||
Returns the last time <nick> was seen and what <nick> was last seen
|
Returns the last time <nick> was seen and what <nick> was last seen
|
||||||
saying. <channel> is only necessary if the message isn't sent on the
|
saying. <channel> is only necessary if the message isn't sent on the
|
||||||
channel itself.
|
channel itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
|
||||||
name = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
results = []
|
results = []
|
||||||
if '*' in name:
|
if '*' in name:
|
||||||
@ -156,29 +154,31 @@ class Seen(callbacks.Privmsg):
|
|||||||
(when, said) = info
|
(when, said) = info
|
||||||
L.append('%s (%s ago)' %
|
L.append('%s (%s ago)' %
|
||||||
(nick, utils.timeElapsed(time.time()-when)))
|
(nick, utils.timeElapsed(time.time()-when)))
|
||||||
irc.reply('%s could be %s' % (name, utils.commaAndify(L, And='or')))
|
irc.reply('%s could be %s' %
|
||||||
|
(name, utils.commaAndify(L, And='or')))
|
||||||
else:
|
else:
|
||||||
irc.reply('I haven\'t seen anyone matching %s' % name)
|
irc.reply('I haven\'t seen anyone matching %s.' % name)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % name)
|
irc.reply('I have not seen %s.' % name)
|
||||||
|
# XXX This should be channeldb, but ChannelUserDictionary does't support it.
|
||||||
|
seen = wrap(seen, ['channel', 'nick'])
|
||||||
|
|
||||||
def last(self, irc, msg, args):
|
def last(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
|
|
||||||
Returns the last thing said in <channel>. <channel> is only necessary
|
Returns the last thing said in <channel>. <channel> is only necessary
|
||||||
if the message isn't sent in the channel itself.
|
if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
|
||||||
try:
|
try:
|
||||||
(when, said) = self.db.seen(channel, '<last>')
|
(when, said) = self.db.seen(channel, '<last>')
|
||||||
irc.reply('Someone was last seen here %s ago saying: %s' %
|
irc.reply('Someone was last seen here %s ago saying: %s' %
|
||||||
(utils.timeElapsed(time.time()-when), said))
|
(utils.timeElapsed(time.time()-when), said))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have never seen anyone.')
|
irc.reply('I have never seen anyone.')
|
||||||
|
last = wrap(last, ['channel'])
|
||||||
|
|
||||||
|
|
||||||
def user(self, irc, msg, args):
|
def user(self, irc, msg, args, channel, user):
|
||||||
"""[<channel>] <name>
|
"""[<channel>] <name>
|
||||||
|
|
||||||
Returns the last time <name> was seen and what <name> was last seen
|
Returns the last time <name> was seen and what <name> was last seen
|
||||||
@ -187,23 +187,13 @@ class Seen(callbacks.Privmsg):
|
|||||||
<channel> is only necessary if the message isn't sent in the channel
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
itself.
|
itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
|
||||||
name = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(name)
|
(when, said) = self.db.seen(channel, user.id)
|
||||||
except KeyError:
|
|
||||||
try:
|
|
||||||
hostmask = irc.state.nickToHostmask(name)
|
|
||||||
id = ircdb.users.getUserId(hostmask)
|
|
||||||
except KeyError:
|
|
||||||
irc.errorNoUser()
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
(when, said) = self.db.seen(channel, id)
|
|
||||||
irc.reply('%s was last seen here %s ago saying: %s' %
|
irc.reply('%s was last seen here %s ago saying: %s' %
|
||||||
(name, utils.timeElapsed(time.time()-when), said))
|
(user.name, utils.timeElapsed(time.time()-when), said))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % name)
|
irc.reply('I have not seen %s.' % name)
|
||||||
|
user = wrap(user, ['channel', 'otherUser'])
|
||||||
|
|
||||||
|
|
||||||
Class = Seen
|
Class = Seen
|
||||||
|
@ -44,6 +44,7 @@ import getopt
|
|||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
@ -138,32 +139,32 @@ class Tail(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
for target in self.registryValue('targets'):
|
for target in self.registryValue('targets'):
|
||||||
irc.reply(payload, to=target, notice=notice, private=True)
|
irc.reply(payload, to=target, notice=notice, private=True)
|
||||||
|
|
||||||
def add(self, irc, msg, args):
|
def add(self, irc, msg, args, filename):
|
||||||
"""<filename>
|
"""<filename>
|
||||||
|
|
||||||
Basically does the equivalent of tail -f to the targets.
|
Basically does the equivalent of tail -f to the targets.
|
||||||
"""
|
"""
|
||||||
filename = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
self._add(filename)
|
self._add(filename)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
irc.error(utils.exnTostring(e))
|
irc.error(utils.exnTostring(e))
|
||||||
return
|
return
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
add = wrap(add, ['filename'])
|
||||||
|
|
||||||
def remove(self, irc, msg, args):
|
def remove(self, irc, msg, args, filename):
|
||||||
"""<filename>
|
"""<filename>
|
||||||
|
|
||||||
Stops announcing the lines appended to <filename>.
|
Stops announcing the lines appended to <filename>.
|
||||||
"""
|
"""
|
||||||
filename = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
self._remove(filename)
|
self._remove(filename)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('I\'m not currently announcing %s.' % filename)
|
irc.error('I\'m not currently announcing %s.' % filename)
|
||||||
|
remove = wrap(remove, ['filename'])
|
||||||
|
|
||||||
def target(self, irc, msg, args):
|
def target(self, irc, msg, args, optlist, targets):
|
||||||
"""[--remove] [<target> ...]
|
"""[--remove] [<target> ...]
|
||||||
|
|
||||||
If given no arguments, returns the current list of targets for this
|
If given no arguments, returns the current list of targets for this
|
||||||
@ -171,12 +172,11 @@ class Tail(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
the current list of targets. If given --remove and any number of
|
the current list of targets. If given --remove and any number of
|
||||||
targets, will remove those targets from the current list of targets.
|
targets, will remove those targets from the current list of targets.
|
||||||
"""
|
"""
|
||||||
(optlist, args) = getopt.getopt(args, '', ['remove'])
|
|
||||||
remove = False
|
remove = False
|
||||||
for (option, arg) in optlist:
|
for (option, arg) in optlist:
|
||||||
if option == '--remove':
|
if option == 'remove':
|
||||||
remove = True
|
remove = True
|
||||||
if not args:
|
if not targets:
|
||||||
L = self.registryValue('targets')
|
L = self.registryValue('targets')
|
||||||
if L:
|
if L:
|
||||||
utils.sortBy(ircutils.toLower, L)
|
utils.sortBy(ircutils.toLower, L)
|
||||||
@ -186,6 +186,8 @@ class Tail(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
elif remove:
|
elif remove:
|
||||||
pass #XXX
|
pass #XXX
|
||||||
|
|
||||||
|
target = wrap(target, [getopts({'remove': ''}), any('something')])
|
||||||
|
|
||||||
|
|
||||||
Class = Tail
|
Class = Tail
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ import struct
|
|||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
@ -121,12 +122,11 @@ conf.registerGlobalValue(conf.supybot.plugins.Unix.wtf, 'command',
|
|||||||
|
|
||||||
|
|
||||||
class Unix(callbacks.Privmsg):
|
class Unix(callbacks.Privmsg):
|
||||||
def errno(self, irc, msg, args):
|
def errno(self, irc, msg, args, s):
|
||||||
"""<error number or code>
|
"""<error number or code>
|
||||||
|
|
||||||
Returns the number of an errno code, or the errno code of a number.
|
Returns the number of an errno code, or the errno code of a number.
|
||||||
"""
|
"""
|
||||||
s = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
i = int(s)
|
i = int(s)
|
||||||
name = errno.errorcode[i]
|
name = errno.errorcode[i]
|
||||||
@ -140,6 +140,7 @@ class Unix(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
name = '(unknown)'
|
name = '(unknown)'
|
||||||
irc.reply('%s (#%s): %s' % (name, i, os.strerror(i)))
|
irc.reply('%s (#%s): %s' % (name, i, os.strerror(i)))
|
||||||
|
errno = wrap(errno, ['something'])
|
||||||
|
|
||||||
def progstats(self, irc, msg, args):
|
def progstats(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
@ -154,10 +155,10 @@ class Unix(callbacks.Privmsg):
|
|||||||
Returns the current pid of the process for this Supybot.
|
Returns the current pid of the process for this Supybot.
|
||||||
"""
|
"""
|
||||||
irc.reply(str(os.getpid()), private=True)
|
irc.reply(str(os.getpid()), private=True)
|
||||||
pid = privmsgs.checkCapability(pid, 'owner')
|
pid = wrap(pid, [('checkCapability', 'owner')])
|
||||||
|
|
||||||
_cryptre = re.compile(r'[./0-9A-Za-z]')
|
_cryptre = re.compile(r'[./0-9A-Za-z]')
|
||||||
def crypt(self, irc, msg, args):
|
def crypt(self, irc, msg, args, password, salt):
|
||||||
"""<password> [<salt>]
|
"""<password> [<salt>]
|
||||||
|
|
||||||
Returns the resulting of doing a crypt() on <password> If <salt> is
|
Returns the resulting of doing a crypt() on <password> If <salt> is
|
||||||
@ -170,12 +171,12 @@ class Unix(callbacks.Privmsg):
|
|||||||
while self._cryptre.sub('', s) != '':
|
while self._cryptre.sub('', s) != '':
|
||||||
s = struct.pack('<h', random.randrange(2**16))
|
s = struct.pack('<h', random.randrange(2**16))
|
||||||
return s
|
return s
|
||||||
(password, salt) = privmsgs.getArgs(args, optional=1)
|
if not salt:
|
||||||
if salt == '':
|
|
||||||
salt = makeSalt()
|
salt = makeSalt()
|
||||||
irc.reply(crypt.crypt(password, salt))
|
irc.reply(crypt.crypt(password, salt))
|
||||||
|
crypt = wrap(crypt, ['something', optional('something')])
|
||||||
|
|
||||||
def spell(self, irc, msg, args):
|
def spell(self, irc, msg, args, word):
|
||||||
"""<word>
|
"""<word>
|
||||||
|
|
||||||
Returns the result of passing <word> to aspell/ispell. The results
|
Returns the result of passing <word> to aspell/ispell. The results
|
||||||
@ -189,7 +190,6 @@ class Unix(callbacks.Privmsg):
|
|||||||
'installed on this computer. If one is installed, '
|
'installed on this computer. If one is installed, '
|
||||||
'reconfigure supybot.plugins.Unix.spell.command '
|
'reconfigure supybot.plugins.Unix.spell.command '
|
||||||
'appropriately.', Raise=True)
|
'appropriately.', Raise=True)
|
||||||
word = privmsgs.getArgs(args)
|
|
||||||
if word and not word[0].isalpha():
|
if word and not word[0].isalpha():
|
||||||
irc.error('<word> must begin with an alphabet character.')
|
irc.error('<word> must begin with an alphabet character.')
|
||||||
return
|
return
|
||||||
@ -228,6 +228,7 @@ class Unix(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
resp = 'Something unexpected was seen in the [ai]spell output.'
|
resp = 'Something unexpected was seen in the [ai]spell output.'
|
||||||
irc.reply(resp)
|
irc.reply(resp)
|
||||||
|
spell = wrap(spell, ['something'])
|
||||||
|
|
||||||
def fortune(self, irc, msg, args):
|
def fortune(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
@ -259,7 +260,7 @@ class Unix(callbacks.Privmsg):
|
|||||||
'supybot.plugins.Unix.fortune.command configuration '
|
'supybot.plugins.Unix.fortune.command configuration '
|
||||||
'variable appropriately.')
|
'variable appropriately.')
|
||||||
|
|
||||||
def wtf(self, irc, msg, args):
|
def wtf(self, irc, msg, args, _, something):
|
||||||
"""[is] <something>
|
"""[is] <something>
|
||||||
|
|
||||||
Returns wtf <something> is. 'wtf' is a *nix command that first
|
Returns wtf <something> is. 'wtf' is a *nix command that first
|
||||||
@ -268,9 +269,6 @@ class Unix(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
wtfCmd = self.registryValue('wtf.command')
|
wtfCmd = self.registryValue('wtf.command')
|
||||||
if wtfCmd:
|
if wtfCmd:
|
||||||
if args and args[0] == 'is':
|
|
||||||
del args[0]
|
|
||||||
something = privmsgs.getArgs(args)
|
|
||||||
something = something.rstrip('?')
|
something = something.rstrip('?')
|
||||||
(r, w) = popen2.popen4([wtfCmd, something])
|
(r, w) = popen2.popen4([wtfCmd, something])
|
||||||
try:
|
try:
|
||||||
@ -284,6 +282,7 @@ class Unix(callbacks.Privmsg):
|
|||||||
'If it is installed on this system, reconfigure the '
|
'If it is installed on this system, reconfigure the '
|
||||||
'supybot.plugins.Unix.wtf.command configuration '
|
'supybot.plugins.Unix.wtf.command configuration '
|
||||||
'variable appropriately.')
|
'variable appropriately.')
|
||||||
|
wtf = wrap(wtf, [optional(('literal', ['is'])), 'something'])
|
||||||
|
|
||||||
|
|
||||||
Class = Unix
|
Class = Unix
|
||||||
|
Loading…
Reference in New Issue
Block a user