当前位置: 首页>>代码示例>>Python>>正文


Python Irc.account_names方法代码示例

本文整理汇总了Python中Irc.account_names方法的典型用法代码示例。如果您正苦于以下问题:Python Irc.account_names方法的具体用法?Python Irc.account_names怎么用?Python Irc.account_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Irc的用法示例。


在下文中一共展示了Irc.account_names方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mtip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def mtip(req, arg):
    """%mtip <targ1> <amt1> [<targ2> <amt2> ...] - Send multiple tips at once"""
    if not len(arg) or len(arg) % 2:
        return req.reply(gethelp("mtip"))
    acct = Irc.account_names([req.nick])[0]
    if not acct:
        return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
    if Transactions.lock(acct):
        return req.reply_private("Your account is currently locked")
    for i in range(0, len(arg), 2):
        try:
            arg[i + 1] = parse_amount(arg[i + 1], acct)
        except ValueError as e:
            return req.reply_private(str(e))
    targets = []
    amounts = []
    total = 0
    for i in range(0, len(arg), 2):
        target = arg[i]
        amount = arg[i + 1]
        found = False
        for i in range(len(targets)):
            if Irc.equal_nicks(targets[i], target):
                amounts[i] += amount
                total += amount
                found = True
                break
        if not found:
            targets.append(target)
            amounts.append(amount)
            total += amount
    balance = Transactions.balance(acct)
    if total > balance:
        return req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (total, balance))
    accounts = Irc.account_names([target_nick(target) for target in targets])
    totip = {}
    failed = ""
    tipped = ""
    for i in range(len(targets)):
        if accounts[i] == None:
            failed += " %s (offline)" % (target_nick(targets[i]))
        elif accounts[i] == False:
            failed += " %s (unidentified)" % (target_nick(targets[i]))
        elif not target_verify(targets[i], accounts[i]):
            failed += " %s (mismatch)" % (targets[i])
        else:
            totip[accounts[i]] = totip.get(accounts[i], 0) + amounts[i]
            tipped += " %s %d" % (target_nick(targets[i]), amounts[i])
    token = Logger.token()
    try:
        Transactions.tip_multiple(token, acct, totip)
        tipped += " [%s]" % (token)
    except Transactions.NotEnoughMoney:
        return req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (total, Transactions.balance(acct)))
    output = "Tipped:" + tipped
    if len(failed):
        output += "  Failed:" + failed
    req.reply(output)
开发者ID:Magicking,项目名称:Doger,代码行数:60,代码来源:Commands.py

示例2: mtip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def mtip(req, arg):
	"""%mtip <targ1> <amt1> [<targ2> <amt2> ...] - Send multiple tips at once"""
	if not len(arg) or len(arg) % 2:
		return req.reply("%mtip <targ1> <amt1> [<targ2> <amt2> ...]")
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	for i in range(0, len(arg), 2):
		try:
			if int(arg[i + 1]) <= 0:
				raise ValueError()
		except ValueError as e:
			req.reply_private(repr(arg[i + 1]) + " - invalid amount")
			return None
	targets = []
	amounts = []
	total = 0
	for i in range(0, len(arg), 2):
		target = arg[i]
		amount = int(arg[i + 1])
		amount = min(amount, 1000000000000)
		found = False
		for i in range(len(targets)):
			if Irc.equal_nicks(targets[i], target):
				amounts[i] += amount
				total += amount
				found = True
				break
		if not found:
			targets.append(target)
			amounts.append(amount)
			total += amount
	balance = Transactions.balance(acct)
	if total > balance:
		return req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (total, balance))
	accounts = Irc.account_names(targets)
	totip = {}
	failed = ""
	tipped = ""
	for i in range(len(targets)):
		if accounts[i]:
			totip[accounts[i]] = amounts[i]
			tipped += " %s %d" % (targets[i], amounts[i])
		elif accounts[i] == None:
			failed += " %s (offline)" % (targets[i])
		else:
			failed += " %s (unidentified)" % (targets[i])
	with Logger.token() as token:
		try:
			Transactions.tip_multiple(acct, totip)
			token.log("t", "acct:%s mtipped: %s" % (acct, repr(totip)))
			tipped += " [%s]" % (token.id)
		except Transactions.NotEnoughMoney:
			return req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (total, Transactions.balance(acct)))
	output = "Tipped:" + tipped
	if len(failed):
		output += "  Failed:" + failed
	req.reply(output)
开发者ID:hashfaster,项目名称:Doger,代码行数:60,代码来源:Commands.py

示例3: _help

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def _help(req, arg):
    """%help - list of commands; %help <command> - help for specific command"""
    if len(arg):
        h = gethelp(arg[0])
        if h:
            req.reply(h)
    else:
        if not Irc.equal_nicks(req.target, req.nick):
            return req.reply("I'm Doger, an IRC dogecoin tipbot. For more info do /msg Doger help")
        acct = Irc.account_names([req.nick])[0]
        if acct:
            ident = "you're identified as \2" + acct + "\2"
        else:
            ident = "you're not identified"
        req.say(
            "I'm Doger, I'm an IRC dogecoin tipbot. To get help about a specific command, say \2%help <command>\2  Commands: %tip %balance %withdraw %deposit %mtip %donate %help".replace(
                "%", Config.config["prefix"]
            )
        )
        req.say(
            (
                "Note that to receive or send tips you should be identified with freenode services (%s). Please consider donating with %%donate. For any support questions, including those related to lost coins, join ##doger"
                % (ident)
            ).replace("%", Config.config["prefix"])
        )
开发者ID:Magicking,项目名称:Doger,代码行数:27,代码来源:Commands.py

示例4: tip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def tip(req, arg):
	"""%tip <target> <amount> - Sends 'amount' coins to the specified nickname"""
	if len(arg) < 2:
		return req.reply(gethelp("tip"))
	to = arg[0]
	acct, toacct = Irc.account_names([req.nick, to])
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if Transactions.lock(acct):
		return req.reply_private("Your account is currently locked")
	if not toacct:
		if toacct == None:
			return req.reply_private(to + " is not online")
		else:
			return req.reply_private(to + " is not identified with freenode services")
	try:
		amount = parse_amount(arg[1], acct)
	except ValueError as e:
		return req.reply_private(str(e))
	token = Logger.token()
	try:
		Transactions.tip(token, acct, toacct, amount)
		if Irc.equal_nicks(req.nick, req.target):
			req.reply("Done [%s]" % (token))
		else:
			req.say("Such %s tipped much Ɖ%i to %s! (to claim /msg Doger help) [%s]" % (req.nick, amount, to, token))
		req.privmsg(to, "Such %s has tipped you Ɖ%i (to claim /msg Doger help) [%s]" % (req.nick, amount, token), priority = 10)
	except Transactions.NotEnoughMoney:
		req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:31,代码来源:Commands.py

示例5: tip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def tip(req, arg):
	"""%tip <target> <amount> - Sends 'amount' coins to the specified nickname. Nickname can be suffixed with @ and an account name, if you want to make sure you are tipping the correct person"""
	if len(arg) < 2:
		return req.reply(gethelp("tip"))
	to = arg[0]
	acct, toacct = Irc.account_names([req.nick, target_nick(to)])
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if Transactions.lock(acct):
		return req.reply_private("Your account is currently locked")
	if not toacct:
		if toacct == None:
			return req.reply_private(target_nick(to) + " is not online")
		else:
			return req.reply_private(target_nick(to) + " is not identified with freenode services")
	if not target_verify(to, toacct):
		return req.reply_private("Account name mismatch")
	try:
		amount = parse_amount(arg[1], acct)
	except ValueError as e:
		return req.reply_private(str(e))
	token = Logger.token()
	try:
		Transactions.tip(token, acct, toacct, amount)
		if Irc.equal_nicks(req.nick, req.target):
			req.reply("Done [%s]" % (token))
		else:
			req.say(" %s tipped BITB%i to %s! (to claim /msg Beaner help) [%s]" % (req.nick, amount, target_nick(to), token))
		req.privmsg(target_nick(to), "%s has tipped you BITB%i (to claim /msg Beaner help) [%s]" % (req.nick, amount, token), priority = 10)
	except Transactions.NotEnoughMoney:
		req.reply_private("You tried to tip BITB%i but you only have BITB%i" % (amount, Transactions.balance(acct)))
开发者ID:Extrememist,项目名称:Doger,代码行数:33,代码来源:Commands.py

示例6: tip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def tip(req, arg):
	"""%tip <target> <amount> - Sends 'amount' coins to the specified nickname"""
	if len(arg) < 2:
		return req.reply("%tip <target> <amount>")
	to = arg[0]
	acct, toacct = Irc.account_names([req.nick, to])
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if not toacct:
		if toacct == None:
			return req.reply_private(to + " is not online")
		else:
			return req.reply_private(to + " is not identified with freenode services")
	try:
		amount = int(arg[1])
		if amount <= 0:
			raise ValueError()
		amount = min(amount, 1000000000000)
	except ValueError as e:
		req.reply_private(repr(arg[1]) + " - invalid amount")
		return None
	with Logger.token() as token:
		try:
			Transactions.tip(acct, toacct, amount)
			token.log("t", "acct:%s tipped %d to acct:%s(%d)" % (acct, amount, toacct, Transactions.balance(toacct)))
			if Irc.equal_nicks(req.nick, req.target):
				req.reply("Done [%s]" % (token.id))
			else:
				req.say("Such %s tipped much Ɖ%i to %s! (to claim /msg Doger help) [%s]" % (req.nick, amount, to, token.id))
			Irc.instance_send(req.instance, "PRIVMSG", to, "Such %s has tipped you Ɖ%i (to claim /msg Doger help) [%s]" % (req.nick, amount, token.id))
		except Transactions.NotEnoughMoney:
			req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:hashfaster,项目名称:Doger,代码行数:34,代码来源:Commands.py

示例7: withdraw

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def withdraw(req, arg):
	"""%withdraw <address> [amount] - Sends 'amount' coins to the specified dogecoin address. If no amount specified, sends the whole balance"""
	if len(arg) == 0:
		return req.reply(gethelp("withdraw"))
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if Transactions.lock(acct):
		return req.reply_private("Your account is currently locked")
	if len(arg) == 1:
		amount = max(Transactions.balance(acct) - 1, 1)
	else:
		try:
			amount = parse_amount(arg[1], acct, all_offset = -1)
		except ValueError as e:
			return req.reply_private(str(e))
	to = arg[0]
	if not Transactions.verify_address(to):
		return req.reply_private(to + " doesn't seem to be a valid dogecoin address")
	token = Logger.token()
	try:
		tx = Transactions.withdraw(token, acct, to, amount)
		req.reply("Coins have been sent, see http://dogechain.info/tx/%s [%s]" % (tx, token))
	except Transactions.NotEnoughMoney:
		req.reply_private("You tried to withdraw Ɖ%i (+Ɖ1 TX fee) but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
	except Transactions.InsufficientFunds:
		req.reply("Something went wrong, report this to mniip [%s]" % (token))
		Logger.irclog("InsufficientFunds while executing '%s' from '%s'" % (req.text, req.nick))
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:30,代码来源:Commands.py

示例8: donate

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def donate(req, arg):
	"""%donate <amount> - Donate 'amount' coins to the developers of this bot"""
	if len(arg) < 1:
		return req.reply(gethelp("donate"))
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if Transactions.lock(acct):
		return req.reply_private("Your account is currently locked")
	toacct = "mniip"
	if arg[0] == "all":
		arg[0] = str(Transactions.balance(acct))
	try:
		amount = float(arg[0])
		if math.isnan(amount):
			raise ValueError
	except ValueError as e:
		return req.reply_private(repr(arg[0]) + " - invalid amount")
	if amount > 1e12:
		return req.reply_private(repr(arg[0]) + " - invalid amount (value too large)")
	if amount < 1:
		return req.reply_private(repr(arg[0]) + " - invalid amount (should be 1 or more)")
	if not int(amount) == amount:
		return req.reply_private(repr(arg[0]) + " - invalid amount (should be integer)")
	amount = int(amount)
	token = Logger.token()
	try:
		Transactions.tip(token, acct, toacct, amount)
		req.reply("Donated Ɖ%i [%s]" % (amount, token))
		req.privmsg(toacct, "Such %s donated Ɖ%i [%s]" % (req.nick, amount, token), priority = 10)
	except Transactions.NotEnoughMoney:
		req.reply_private("You tried to donate Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:xeddmc,项目名称:Doger,代码行数:34,代码来源:Commands.py

示例9: withdraw

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def withdraw(req, arg):
	"""%withdraw <address> [amount] - Sends 'amount' coins to the specified dogecoin address. If no amount specified, sends the whole balance"""
	if len(arg) == 0:
		return req.reply("%withdraw <address> [amount]")
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if len(arg) == 1:
		amount = max(Transactions.balance(acct) - 1, 1)
	else:
		try:
			amount = int(arg[1])
			if amount <= 0:
				raise ValueError()
			amount = min(amount, 1000000000000)
		except ValueError as e:
			req.reply_private(repr(arg[1]) + " - invalid amount")
			return None
	to = arg[0]
	if not Transactions.verify_address(to):
		return req.reply_private(to + " doesn't seem to be a valid dogecoin address")
	with Logger.token() as token:
		try:
			tx = Transactions.withdraw(acct, to, amount)
			token.log("t", "acct:%s withdrew %d, TX id is %s (acct:%s(%d))" % (acct, amount, tx, acct, Transactions.balance(acct)))
			req.reply("Coins have been sent, see http://dogechain.info/tx/%s [%s]" % (tx, token.id))
		except Transactions.NotEnoughMoney:
			req.reply_private("You tried to withdraw Ɖ%i (+Ɖ1 TX fee) but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
		except Transactions.InsufficientFunds:
			token.log("te", "acct:%s tried to withdraw %d" % (acct, amount))
			req.reply("Something went wrong, report this to mniip [%s]" % (token.id))
开发者ID:hashfaster,项目名称:Doger,代码行数:33,代码来源:Commands.py

示例10: deposit

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def deposit(req, _):
    """%deposit - Displays your deposit address"""
    acct = Irc.account_names([req.nick])[0]
    if not acct:
        return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
    req.reply_private(
        "To deposit, send coins to %s (transactions will be credited after %d confirmations)"
        % (Transactions.deposit_address(acct), Config.config["confirmations"])
    )
开发者ID:Magicking,项目名称:Doger,代码行数:11,代码来源:Commands.py

示例11: balance

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def balance(req, _):
	"""%balance - Displays your confirmed and unconfirmed balance"""
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	confirmed = Transactions.balance(acct)
	pending = Transactions.balance_unconfirmed(acct)
	if pending:
		req.reply("Your balance is Ɖ%i (+Ɖ%i unconfirmed)" % (confirmed, pending))
	else:
		req.reply("Your balance is Ɖ%i" % (confirmed))
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:13,代码来源:Commands.py

示例12: donate

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def donate(req, arg):
	"""%donate <amount> - Donate 'amount' coins to help fund the server Doger is running on"""
	if len(arg) < 1:
		return req.reply(gethelp("donate"))
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if Transactions.lock(acct):
		return req.reply_private("Your account is currently locked")
	toacct = "@DONATIONS"
	try:
		amount = parse_amount(arg[0], acct)
	except ValueError as e:
		return req.reply_private(str(e))
	token = Logger.token()
	try:
		Transactions.tip(token, acct, toacct, amount)
		req.reply("Donated Ɖ%i, thank you very much for your donation [%s]" % (amount, token))
	except Transactions.NotEnoughMoney:
		req.reply_private("You tried to donate Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:22,代码来源:Commands.py

示例13: _help

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def _help(req, arg):
	"""%help - list of commands; %help <command> - help for specific command"""
	if len(arg):
		if arg[0][0] == '%':
			name = arg[0][1:]
		else:
			name = arg[0]
		cmd = commands.get(name, None)
		if cmd and cmd.__doc__:
			req.reply(cmd.__doc__.split("\n")[0])
	else:
		if not Irc.equal_nicks(req.target, req.nick):
			return req.reply("I'm Doger, an IRC dogecoin tipbot. For more info do /msg Doger help")
		acct = Irc.account_names([req.nick])[0]
		if acct:
			ident = "you're identified as \2" + acct + "\2"
		else:
			ident = "you're not identified"
		req.say("I'm Doger, I'm an IRC dogecoin tipbot. To get help about a specific command, say \2%help <command>\2  Commands: %tip %balance %withdraw %deposit %mtip %donate %help")
		req.say("Note that to receive or send tips you should be identified with freenode services (%s). For any support questions, including those related to lost coins, join ##doger" % (ident))
开发者ID:hashfaster,项目名称:Doger,代码行数:22,代码来源:Commands.py

示例14: donate

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def donate(req, arg):
	if len(arg) < 1:
		return req.reply("%donate <amount>")
	acct = Irc.account_names([req.nick])[0]
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	toacct = "@DONATIONS"
	try:
		amount = int(arg[0])
		if amount <= 0:
			raise ValueError()
		amount = min(amount, 1000000000000)
	except ValueError as e:
		req.reply_private(repr(arg[0]) + " - invalid amount")
		return None
	with Logger.token() as token:
		try:
			Transactions.tip(acct, toacct, amount)
			token.log("t", "acct:%s tipped %d to acct:%s(%d)" % (acct, amount, toacct, Transactions.balance(toacct)))
			req.reply("Done [%s]" % (token.id))
		except Transactions.NotEnoughMoney:
			req.reply_private("You tried to donate Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:hashfaster,项目名称:Doger,代码行数:24,代码来源:Commands.py

示例15: test

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import account_names [as 别名]
def test(req, arg):
	req.reply(repr(Irc.account_names(arg)))
开发者ID:hashfaster,项目名称:Doger,代码行数:4,代码来源:Commands.py


注:本文中的Irc.account_names方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。