コード例 #1
0
ファイル: twitter.py プロジェクト: NURDspace/jsonbot
def handle_twitter_confirm(bot, ievent):
    """ arguments: <PIN code> - confirm auth with PIN. """
    from jsb.utils.twitter import go
    if not go: ievent.reply("the twitter plugin needs the credentials.py file in the %s/config dir. see .jsb/data/examples" % getdatadir()) ; return
    pin = ievent.args[0]
    if not pin: ievent.missing("<PIN> .. see the twitter-auth command.") ; return
    try: access_token = getauth(getdatadir()).get_access_token(pin)
    except (tweepy.TweepError, urllib2.HTTPError), e: ievent.reply('twitter failed: %s' % (str(e),)) ; return
    twitteruser = get_users()
    twitteruser.add(ievent.user.data.name, access_token.to_string())
    ievent.reply("access token saved.")
コード例 #2
0
ファイル: twitter.py プロジェクト: NURDspace/jsonbot
def handle_twitter_auth(bot, ievent):
    """ no arguments - get url to get the auth PIN needed for the twitter-confirm command. """
    from jsb.utils.twitter import go
    if not go: ievent.reply("the twitter plugin needs the credentials.py file in the .jsb/data/config dir. see .jsb/data/examples") ; return
    try: auth_url = getauth(getdatadir()).get_authorization_url()
    except (tweepy.TweepError, urllib2.HTTPError), e: ievent.reply('twitter failed: %s' % (str(e),)) ; return
    if bot.type == "irc":
        bot.say(ievent.nick, "sign in at %s" % auth_url)
        bot.say(ievent.nick, "use the provided code in the twitter-confirm command.")
    else:
        ievent.reply("sign in at %s" % auth_url)
        ievent.reply("use the provided code in the twitter-confirm command.")
コード例 #3
0
def handle_twitter_auth(bot, ievent):
    """ no arguments - get url to get the auth PIN needed for the twitter-confirm command. """
    from jsb.utils.twitter import go
    if not go:
        ievent.reply(
            "the twitter plugin needs the credentials.py file in the .jsb/data/config dir. see .jsb/data/examples"
        )
        return
    try:
        auth_url = getauth(getdatadir()).get_authorization_url()
    except (tweepy.TweepError, urllib2.HTTPError), e:
        ievent.reply('twitter failed: %s' % (str(e), ))
        return
コード例 #4
0
def handle_twitter_confirm(bot, ievent):
    """ arguments: <PIN code> - confirm auth with PIN. """
    from jsb.utils.twitter import go
    if not go:
        ievent.reply(
            "the twitter plugin needs the credentials.py file in the %s/config dir. see .jsb/data/examples"
            % getdatadir())
        return
    pin = ievent.args[0]
    if not pin:
        ievent.missing("<PIN> .. see the twitter-auth command.")
        return
    try:
        access_token = getauth(getdatadir()).get_access_token(pin)
    except (tweepy.TweepError, urllib2.HTTPError), e:
        ievent.reply('twitter failed: %s' % (str(e), ))
        return