pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

AttributeError: 'str' object has no attribute 'add'

Open BreezDev opened this issue 3 years ago • 1 comments

I am creating a Telegram bot that gives people access to my bot. I was previously working with datetime and had no issues, but switched to pendelum because I like that it's easier to use.

For my project I am using SQL and Python 3

My regular code:

`@bot.message_handler(content_types=["text"], func=lambda message: message.text == "!!1 Day")
def add_user(message):
    send = bot.send_message(message.chat.id, "Enter UserID: ")
    bot.register_next_step_handler(send, createtest_user)


def createtest_user(message):
    try:
        name = message.from_user.first_name
        user = message.chat.username
        userid = message.text
        delete_specific_UserData(userid)
        create_user_test(userid)
        bot.send_message(message.chat.id, f"Added user for Test calls \n\n"
                                          "Use /start for other functionality\n"
                                          "Good bye")
    except:
        bot.send_message(message.chat.id, "Invalid Option ❌\nUse /start command")

        return ''`

Now, it won't let me add users to my bot unless I manually add them to my database. Everything with my SQL is perfectly fine.

def create_user_test(userid): exp_day_test = dt.add(hours=24) sql = "Hidden for privacy purposes" c.execute(sql) conn.commit()

I keep getting this error: AttributeError: 'str' object has no attribute 'add'

How could I fix this?

BreezDev avatar Aug 19 '22 02:08 BreezDev

I guess you could be facing on of these issues: https://github.com/sdispater/pendulum#limitations

Secrus avatar Aug 24 '22 08:08 Secrus