Change changeusername to changename.

This commit is contained in:
Jeremy Fincher 2003-12-09 00:02:51 +00:00
parent fc1fc32a01
commit fe9bf97a59
3 changed files with 27 additions and 26 deletions

View File

@ -1,13 +1,13 @@
2003-12-6 Jeremy Fincher <jemfinch@supybot.org> 2003-12-6 Jeremy Fincher <jemfinch@supybot.org>
* Added Math.icalc, a new command for doing integer arithmetic.
It requires...
* Added a "trusted" capability that defaults to off (-trusted) and * Added a "trusted" capability that defaults to off (-trusted) and
is required for Utilities.re (with which it's possible to DoS the is required for Utilities.re (with which it's possible to DoS the
bot) and for the new Math.icalc (with which it is trivially bot) and for the new Math.icalc (with which it is trivially
possible to DoS the bot). possible to DoS the bot).
* Added Math.icalc, a new command for doing integer arithmetic.
It requires the "trusted" capability.
* Added the Fun.ping command, because MozBot has it. * Added the Fun.ping command, because MozBot has it.
* Added Note.unsend command, to allow users to "unsend" notes * Added Note.unsend command, to allow users to "unsend" notes
@ -32,6 +32,8 @@
* Added a swap function to Math.rpn. * Added a swap function to Math.rpn.
* Changed the name of User.changeusername to User.changename.
* Changed the logging infrastructure significantly; each plugin * Changed the logging infrastructure significantly; each plugin
now has its own logger (and thus logfile), in addition to being now has its own logger (and thus logfile), in addition to being
logged in the main logfile. logged in the main logfile.

View File

@ -53,9 +53,7 @@ import callbacks
class User(callbacks.Privmsg): class User(callbacks.Privmsg):
def _checkNotChannel(self, irc, msg, password=' '): def _checkNotChannel(self, irc, msg, password=' '):
if password and ircutils.isChannel(msg.args[0]): if password and ircutils.isChannel(msg.args[0]):
irc.error(msg, conf.replyRequiresPrivacy) raise callbacks.Error, conf.replyRequiresPrivacy
return False
else: return True
def list(self, irc, msg, args): def list(self, irc, msg, args):
"""[<glob>] """[<glob>]
@ -98,8 +96,7 @@ class User(callbacks.Privmsg):
for (option, arg) in optlist: for (option, arg) in optlist:
if option == '--hashed': if option == '--hashed':
hashed = True hashed = True
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
try: try:
ircdb.users.getUserId(name) ircdb.users.getUserId(name)
irc.error(msg, 'That name is already assigned to someone.') irc.error(msg, 'That name is already assigned to someone.')
@ -128,8 +125,7 @@ class User(callbacks.Privmsg):
Unregisters <name> from the user database. Unregisters <name> from the user database.
""" """
(name, password) = privmsgs.getArgs(args, required=2) (name, password) = privmsgs.getArgs(args, required=2)
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
try: try:
id = ircdb.users.getUserId(name) id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
@ -142,7 +138,7 @@ class User(callbacks.Privmsg):
else: else:
irc.error(msg, conf.replyIncorrectAuth) irc.error(msg, conf.replyIncorrectAuth)
def changeusername(self, irc, msg, args): def changename(self, irc, msg, args):
"""<name> <new name> [<password>] """<name> <new name> [<password>]
Changes your current user database name to the new name given. Changes your current user database name to the new name given.
@ -150,9 +146,8 @@ class User(callbacks.Privmsg):
If you include the <password> parameter, this message must be sent If you include the <password> parameter, this message must be sent
to the bot privately (not on a channel). to the bot privately (not on a channel).
""" """
(name, newname, password) = privmsgs.getArgs(args, required=2,optional=1) (name,newname,password) = privmsgs.getArgs(args,required=2,optional=1)
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
try: try:
id = ircdb.users.getUserId(name) id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
@ -179,8 +174,7 @@ class User(callbacks.Privmsg):
be sent to the bot privately (not on a channel). be sent to the bot privately (not on a channel).
""" """
(name, hostmask, password) = privmsgs.getArgs(args, 2, 1) (name, hostmask, password) = privmsgs.getArgs(args, 2, 1)
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
if not ircutils.isUserHostmask(hostmask): if not ircutils.isUserHostmask(hostmask):
irc.error(msg, 'That\'s not a valid hostmask.') irc.error(msg, 'That\'s not a valid hostmask.')
return return
@ -219,8 +213,7 @@ class User(callbacks.Privmsg):
this message must be sent to the bot privately (not on a channel). this message must be sent to the bot privately (not on a channel).
""" """
(name, hostmask, password) = privmsgs.getArgs(args, 2, 1) (name, hostmask, password) = privmsgs.getArgs(args, 2, 1)
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
try: try:
id = ircdb.users.getUserId(name) id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
@ -253,8 +246,7 @@ class User(callbacks.Privmsg):
for (option, arg) in optlist: for (option, arg) in optlist:
if option == '--hashed': if option == '--hashed':
hashed = True hashed = True
if not self._checkNotChannel(irc, msg, oldpassword+newpassword): self._checkNotChannel(irc, msg, oldpassword+newpassword)
return
try: try:
id = ircdb.users.getUserId(name) id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
@ -337,8 +329,7 @@ class User(callbacks.Privmsg):
not in a channel. not in a channel.
""" """
(name, password) = privmsgs.getArgs(args, 2) (name, password) = privmsgs.getArgs(args, 2)
if not self._checkNotChannel(irc, msg): self._checkNotChannel(irc, msg)
return
try: try:
id = ircdb.users.getUserId(name) id = ircdb.users.getUserId(name)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)
@ -393,8 +384,7 @@ class User(callbacks.Privmsg):
value. value.
""" """
(password, value) = privmsgs.getArgs(args, optional=1) (password, value) = privmsgs.getArgs(args, optional=1)
if not self._checkNotChannel(irc, msg, password): self._checkNotChannel(irc, msg, password)
return
try: try:
id = ircdb.users.getUserId(msg.prefix) id = ircdb.users.getUserId(msg.prefix)
user = ircdb.users.getUser(id) user = ircdb.users.getUser(id)

View File

@ -31,12 +31,21 @@
from testsupport import * from testsupport import *
import world
import ircdb import ircdb
class UserTestCase(PluginTestCase, PluginDocumentation): class UserTestCase(PluginTestCase, PluginDocumentation):
plugins = ('User',) plugins = ('User',)
prefix1 = 'somethingElse!user@host.tld' prefix1 = 'somethingElse!user@host.tld'
prefix2 = 'EvensomethingElse!user@host.tld' prefix2 = 'EvensomethingElse!user@host.tld'
## def testHostmasks(self):
## self.assertNotError('hostmasks')
## original = self.prefix
## self.prefix = self.prefix1
## self.assertNotError('register foo bar')
## self.prefix = original
## self.assertRegexp('hostmasks foo', 'only.*your.*own')
def testRegisterUnregister(self): def testRegisterUnregister(self):
self.prefix = self.prefix1 self.prefix = self.prefix1
self.assertNotError('register foo bar') self.assertNotError('register foo bar')
@ -73,8 +82,8 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
self.prefix = self.prefix2 self.prefix = self.prefix2
self.assertNotError('register bar baz') self.assertNotError('register bar baz')
self.prefix = self.prefix1 self.prefix = self.prefix1
self.assertError('changeusername foo bar') self.assertError('changename foo bar')
self.assertNotError('changeusername foo baz') self.assertNotError('changename foo baz')
def testSetpassword(self): def testSetpassword(self):
self.prefix = self.prefix1 self.prefix = self.prefix1