def link(ctx, account, network): """ Link account. Link your account to another network. This account will then become the primary account, and the other account made an alias of the account requesting linkage. """ try: user_data = yield ctx.lookup_user_data() except UserData.DoesNotExist: ctx.respond( ctx._("Please log in to NickServ before linking an account.")) return try: alt_client, *_ = [ client for client in ctx.bot.clients.values() if client.network == network ] except ValueError: ctx.respond(ctx._("I can't find that network.")) return alt_user_data = yield UserData.lookup_default(alt_client, account) if user_data.account == alt_user_data.account and \ user_data.network == alt_user_data.network: ctx.respond(ctx._("You can't link your account to itself.")) return if "_alias" in alt_user_data: ctx.respond(ctx._("You can't link your account to an alias.")) return ctx.respond( ctx. _("Okay, please message me \"!confirmlink {account} {network}\" on that network." ).format(account=ctx.origin, network=ctx.client.network)) yield wait_for_confirmation(ctx.storage, ctx.origin, ctx.client.network, account, network) data = dict(alt_user_data) data.update(user_data) user_data.update(data) user_data.save() alt_user_data.clear() alt_user_data["_alias"] = { "account": user_data.account, "network": user_data.network } alt_user_data.save() ctx.respond( ctx. _("Your account has been successfully linked with {account} on {network}." ).format(account=account, network=network))
def link(ctx, account, network): """ Link account. Link your account to another network. This account will then become the primary account, and the other account made an alias of the account requesting linkage. """ try: user_data = yield ctx.lookup_user_data() except UserData.DoesNotExist: ctx.respond(ctx._("Please log in to NickServ before linking an account.")) return try: alt_client, *_ = [client for client in ctx.bot.clients.values() if client.network == network] except ValueError: ctx.respond(ctx._("I can't find that network.")) return alt_user_data = yield UserData.lookup_default(alt_client, account) if user_data.account == alt_user_data.account and \ user_data.network == alt_user_data.network: ctx.respond(ctx._("You can't link your account to itself.")) return if "_alias" in alt_user_data: ctx.respond(ctx._("You can't link your account to an alias.")) return ctx.respond(ctx._("Okay, please message me \"!confirmlink {account} {network}\" on that network.").format( account=ctx.origin, network=ctx.client.network )) yield wait_for_confirmation(ctx.storage, ctx.origin, ctx.client.network, account, network) data = dict(alt_user_data) data.update(user_data) user_data.update(data) user_data.save() alt_user_data.clear() alt_user_data["_alias"] = { "account": user_data.account, "network": user_data.network } alt_user_data.save() ctx.respond(ctx._("Your account has been successfully linked with {account} on {network}.").format( account=account, network=network ))
def get_karma(ctx, who): """ Get karma. Get the amount of karma for a user. """ user_data = yield UserData.lookup_default(ctx.client, who) karma = user_data.get("karma", 0) ctx.respond(ctx._("{who} has {n} karma.").format(who=who, n=karma))
def get_karma(ctx, who): """ Get karma. Get the amount of karma for a user. """ user_data = yield UserData.lookup_default(ctx.client, who) karma = user_data.get("karma", 0) ctx.respond(ctx._("{who} has {n} karma.").format( who=who, n=karma ))
def get_profile(ctx, who=None): """ Get profile. Retrieve profile text for a user. """ if who is None: who = ctx.origin user_data = yield UserData.lookup_default(ctx.client, who) if "profile" not in user_data: ctx.respond(ctx._("{who} hasn't told me who they are yet.").format( who=who )) return ctx.respond(ctx._("{who} is {text}").format( who=who, text=user_data["profile"] ))
def get_lfm_username(client, who): user_data = yield UserData.lookup_default(client, who) return user_data.get("lastfm_user", who)
def get_lfm_username(client, who): user_data = yield UserData.lookup_default(client, who) return user_data.get("lastfm_user", who)