VickiLanger / LGBTQ-of-the-day-bot

Twitter bot tweeting fun goofy lgbtq things and queer history of the day
https://twitter.com/LGBTQotd
GNU General Public License v3.0
80 stars 172 forks source link

Annual Events Tweeting Error #279

Closed VickiLanger closed 3 years ago

VickiLanger commented 3 years ago

Describe the bug tweet_annual_events.py is tweeting Today is [] (example)

Screen Shot of twitter: LGBTQ of The Day
@LgbtQotd - Nov 22 - Today is []

2020-11-23T17:13:11.861843+00:00 app[scheduler.1873]: Traceback (most recent call last):
2020-11-23T17:13:11.861871+00:00 app[scheduler.1873]:   File "tweet_annual_days.py", line 60, in <module>
2020-11-23T17:13:11.861977+00:00 app[scheduler.1873]:     tweet_annual_event()
2020-11-23T17:13:11.861978+00:00 app[scheduler.1873]:   File "tweet_annual_days.py", line 53, in tweet_annual_event
2020-11-23T17:13:11.862116+00:00 app[scheduler.1873]:     event_tweet = tweet_template + list_of_event_tweets[0]  # str(list_of_event_tweets) == ['a good day for testing yet another feature in production. We now support annual events with variable dates like "5th Friday of October"']
2020-11-23T17:13:11.862117+00:00 app[scheduler.1873]: TypeError: must be str, not list

I added the str() to line 51 & 53 because both gave TypeError: must be str, not list. Weird that it gave the error though because it was working fine before that. https://github.com/VickiLanger/LGBTQ-of-the-day-bot/commit/458011e34a15f931b7ccda50558df60ed769e31a#diff-35adfeb78198446941a15787967ce372f9106ac2373e821bcb6d8a5e180456ce

https://github.com/VickiLanger/LGBTQ-of-the-day-bot/blob/3196de8a0ed16f21776506e761aae61cbd749b33/tweet_annual_days.py#L51

https://github.com/VickiLanger/LGBTQ-of-the-day-bot/blob/ca761fb4302dde69e365e6e3cc7f1ee1506e2529/tweet_annual_days.py#L53

    if length_list_event_tweets != 0:
        if length_list_event_tweets > 1:
            event_tweet = tweet_template + str(choice(list_of_event_tweets))
        else:
            event_tweet = tweet_template + list_of_event_tweets[0]  # str(list_of_event_tweets) == ['a good day for testing yet another feature in production. We now support annual events with variable dates like "5th Friday of October"']
        api.update_status(event_tweet)
        print('annual event tweet accomplished')
    else:
        print('no annual event tweet today')

To Reproduce Currently, running and posting as Today is [] daily at 1130 EST/430 UTC

Expected behavior It should instead be tweeting the first item of list_of_event_tweets. Should only tweet the first event in list_of_event_tweets if there is an event or print to logs no annual event tweet today

Additional context For reference, the next 3 events are

    '12-01': 'Wolrd AIDS day \n #WorldAIDSDay',  # http://www.worldaidsday.org/about
    '12-08': 'Pansexual Pride Day',  # https://www.queerevents.ca/notable-lgbtq-dates#pansexualprideday
    '12-10': 'Human Rights Day',  # https://www.un.org/en/observances/human-rights-day

Don't forget to follow the bot on Twitter to see the hard work you put in.

lhfaguiar commented 3 years ago

https://github.com/VickiLanger/LGBTQ-of-the-day-bot/pull/283

VickiLanger commented 3 years ago

283

Still getting an error. I'm sure it's a quick fix.

2020-11-30T16:31:01.915475+00:00 app[scheduler.9307]: Traceback (most recent call last):
2020-11-30T16:31:01.915517+00:00 app[scheduler.9307]:   File "tweet_annual_days.py", line 63, in <module>
2020-11-30T16:31:01.915727+00:00 app[scheduler.9307]:     tweet_annual_event()
2020-11-30T16:31:01.915795+00:00 app[scheduler.9307]:   File "tweet_annual_days.py", line 56, in tweet_annual_event
2020-11-30T16:31:01.916022+00:00 app[scheduler.9307]:     event_tweet = tweet_template + str(list_of_event_tweets[0])  
2020-11-30T16:31:01.916071+00:00 app[scheduler.9307]: IndexError: list index out of range
lhfaguiar commented 3 years ago

oh no!! I'l run some more tests here :(

lhfaguiar commented 3 years ago

https://github.com/VickiLanger/LGBTQ-of-the-day-bot/pull/286

hopefully this is the last update to get it up and running

VickiLanger commented 3 years ago

@lhfaguiar Thank you so much for fixing it. Production is back to working properly!