Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/purk
diff options
context:
space:
mode:
authorEduardo Silva <edsiper@gmail.com>2008-01-04 04:03:10 (GMT)
committer Eduardo Silva <edsiper@gmail.com>2008-01-04 04:03:10 (GMT)
commitac9fc470319b2f2f9232e6c9c16d0780ee8945e4 (patch)
tree90d159c59c13877582eb55ff6e651ee82d321ada /purk
parenta1c8d96e6d7ea2fbf57da6db183fb38d05f9d338 (diff)
Fix default nickname issue (#5385), thanks to Phil_Bordelon!
Diffstat (limited to 'purk')
-rw-r--r--purk/irc.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/purk/irc.py b/purk/irc.py
index e88e43a..5978c3a 100644
--- a/purk/irc.py
+++ b/purk/irc.py
@@ -43,8 +43,32 @@ def default_nicks():
try:
nicks = [conf.get('nick')] + conf.get('altnicks',[])
if not nicks[0]:
- import getpass
- nicks = [getpass.getuser()]
+ # We're going to generate a nick based on the user's nick name
+ # and their public key.
+ import sugar.profile
+ import hashlib
+
+ user_name = sugar.profile.get_nick_name()
+ pubkey = sugar.profile.get_pubkey()
+ m = hashlib.sha1()
+ m.update(pubkey)
+ hexhash = m.hexdigest()
+
+ # Okay. Get all of the alphabetic bits of the username:
+ user_name_letters = "".join([x for x in user_name if x.isalpha()])
+
+ # If that came up with nothing, make it 'XO'. Also, shorten it
+ # if it's more than 11 characters (as we need 5 for - and the
+ # hash).
+ if len(user_name_letters) == 0:
+ user_name_letters = "XO"
+ if len(user_name_letters) > 11:
+ user_name_letters = user_name_letters[0:11]
+
+ # Finally, generate a nick by using those letters plus the first
+ # four hash bits of the user's public key.
+ user_nick = user_name_letters + "-" + hexhash[0:4]
+ nicks = [user_nick]
except:
nicks = ["mrurk"]
return nicks