示例#1
0
def signature(user):
    user_grp = get_user_by_name(user)
    im = Image.open(conf.sig.bg)
    # Write User Nick
    draw = ImageDraw.Draw(im)
    font = ImageFont.truetype(font=conf.sig.nick_font, size=conf.sig.nick_size)
    w, h = draw.textsize(user, font=font)
    draw.text(((360 - w) / 2, 42), user, (0, 100, 255), font=font)
    nick_w = (360 - w) / 2
    # Paste Char img
    imp = Image.open('static/img/Char Renders/%s.png' % user)
    x, y = imp.size
    l, r = (int((360 - w) / 2) - x - 10, 27)
    x, y = (x + l, y + r)
    im.paste(imp, box=(l, r, x, y), mask=imp)
    # Write User Group
    font = ImageFont.truetype(font=conf.sig.group_font, size=conf.sig.group_size)
    group = user_grp[4].replace('vip', 'VIP').replace('default', 'Regular Player').replace('newadmin', 'Moderator').replace('admin', 'Admin').replace('superAdmin', 'Super Admin')
    w, h = draw.textsize(group, font=font)
    draw.text(((360 - w) - 10, (95 - h) - 3), group, (0, 0, 0), font=font)
    im.save('static/img/signatures/%s.png' % user)
    # Paste Inventory
    get_player_inv_sig(user, nick_w)
示例#2
0
 def get_by_username(username):
     try:
         userdb = get_user_by_name(username)
         return User(userdb[0], userdb[2])
     except:
         return None