开发者

Not sure why this data isn't being checked... Tweepy, Python 2.7

if thisuser["handle"] == "Talon":
    tweet_text = thisuser["handle"] + ", the Eternal Leader of Civitas Nihilium, has just logged into the trans-dimensional portal, and is available to converse!"
else:
    tweet_text = thisuser["handle"] + " has just logged into the trans-dimensional portal, and is available to converse!"

I am fairly new to Python and programming in general, so I'm not sure why this isn't working for me. This is Mystic Python which is based on Python 2.7. As you can see the...

Prior to adding this IF statement, the code worked perfectly.

thisuser["handle"] will sometimes have the string "Talon" inside of it. When that is true I'd like to tweet the text with the tweet_text string within it. That isn't happening so what have I done wrong here?

I know this is probably a simple answer, which makes it all the more frustrating. Thank you in advance.

James :)

Here is the full code...

import tweepy
import sys
from mystic_bbs import *

consumer_key = 'yVRqcf4IDbs4IjrQGqiE0gT3n'
consumer_secret = 'ALLwUd0nuXvHA8jrMKfu5CRdy0BwOa72EXaklbdWyB6wYf57X7'
access_token = '1599041954221785089-iMfpEhEEZqaAwc0Bi0SAcshF6oUVw7'
access_token_secret = 'NJhcJGkpH1dhfX9UX5qcSwFxHu4gHv9f62PdoKDnJgLPY'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
thisuser = getuser(0); # read the currently logged in user into thisuser

writeln("|11 STANDBY Updating Status within Profundum!");
api = tweepy.AP开发者_开发问答I(auth)

if thisuser["handle"] == "Talon":
        tweet_text = thisuser["handle"] + ", the Eternal Leader of Civitas Nihilium, has just logged into the trans-dimensional portal, and is available to converse!"
else:
        tweet_text = thisuser["handle"] + " has just logged into the trans-dimensional portal, and is available to converse!"


api.update_status(status=tweet_text)

So what thisuser["handle"] is, is the username of the person logging into my BBS. In this case the username Talon. The tweet that is sent looks like this...

TALON has just logged into the trans-dimensional portal, and is available to converse!"


Oh now I feel embarrassed - I worked it out just by looking at the end product. Talon should be TALON, as the BBS python sets the username to uppercase by default, regardless of what the user enters. Sheesh.

Sorry for wasting everyone's time, hopefully another beginner to Mystic BBS will see this and it'll help them. Thanks guys!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜