leogomezz4t / PyTextNow_API

Python texting API utilizing TextNow API
MIT License
67 stars 41 forks source link

No Module #11

Closed GorboducRex closed 3 years ago

GorboducRex commented 3 years ago

Installed the latest TNAPI: Successfully installed TNAPI-1.0.0 aiohttp-3.7.4.post0 async-timeout-3.0.1 attrs-20.3.0 multidict-5.1.0 yarl-1.6.3 Went to run code that included this line: import TNAPI Got: ModuleNotFoundError: No module named 'TNAPI' Tried lowercase: ModuleNotFoundError: No module named 'tnapi'

leogomezz4t commented 3 years ago

oh the import namespace is TNAPI but the PyPi name is pytextnow the command is pip3 install pytextnow

GorboducRex commented 3 years ago

ModuleNotFoundError: No module named 'pytextnow'

leogomezz4t commented 3 years ago

Sorry the namespace is sort of confusing. You install with pip3 install pytextnow but you use

import TNAPI
GorboducRex commented 3 years ago
$ pip3 install pytextnow
Collecting pytextnow
  Downloading PyTextNow-0.9.6-py3-none-any.whl (7.1 kB)
Requirement already satisfied: requests>2 in /usr/lib/python3/dist-packages (from pytextnow) (2.22.0)
Installing collected packages: pytextnow
Successfully installed pytextnow-0.9.6

In my code: import TNAPI

Result: FileNotFoundError: [Errno 2] No such file or directory: '\\user_sids.json'

Sorry to be such a pain.

leogomezz4t commented 3 years ago

Its alright. Someone else had this issue and I thought I had patched it. Are you on linux

leogomezz4t commented 3 years ago

Ok It should be patched in the latest version

GorboducRex commented 3 years ago

I am. Ubuntu 20.04.2, if it matters. As I mentioned, "\" means nothing to Linux. If you want something in the user's home directory, you'd use "~/" as in "~/user_sids.json" - that would put the file in the user's home directory.

GorboducRex commented 3 years ago

Closer! Now you've got a misspelling:

user_SID_filepath = "\\".join(abspath(__file__).replacce("/", "\\").split("\\")[:-1]) + "\\user_sids.json"
AttributeError: 'str' object has no attribute 'replacce'
leogomezz4t commented 3 years ago

HaHa rush job.

GorboducRex commented 3 years ago

Sorry; now we're back to

FileNotFoundError: [Errno 2] No such file or directory: '\\user_sids.json'

GorboducRex commented 3 years ago

But I really appreciate your hard work on this!

leogomezz4t commented 3 years ago

Yeah I know I just made a much larger patch to the project.

leogomezz4t commented 3 years ago

Ok finally it should be fully functional lmao

GorboducRex commented 3 years ago

And we're back to:

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

GorboducRex commented 3 years ago

Hey, if it was easy, anybody could do it!

leogomezz4t commented 3 years ago

hahaha thank you

leogomezz4t commented 3 years ago

I just did a test of the current version of pytextnow and it is fully functional Try uninstalling and reinstalling

GorboducRex commented 3 years ago

Go to https://www.textnow.com/messaging and open developer tools Open application tab and copy connect.sid cookie and paste it here.

I didn't realize I'd have to sign up as a developer with them myself. That's a limitation I didn't understand. I don't particularly want to do that. I guess I'll do that later. Thanks for all you hard work and attention.

leogomezz4t commented 3 years ago

On Mon, Mar 22, 2021 at 2:15 PM GorboducRex @.***> wrote:

Go to https://www.textnow.com/messaging and open developer tools Open application tab and copy connect.sid cookie and paste it here.

I didn't realize I'd have to sign up as a developer with them myself. That's a limitation I didn't understand. I don't particularly want to do that. I guess I'll do that later. Thanks for all you hard work and attention.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/leogomezz4t/PyTextNow_API/issues/11#issuecomment-804363544, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQV6RXS62PWCEX44QJB327DTE6QMRANCNFSM4ZTVJQ5Q .

No you don’t have to. Developer tools is a feature on google that you can use to see cookies from that website.

GorboducRex commented 3 years ago

Got it! Didn't understand which developer tools you were talking about. Thanks.

GorboducRex commented 3 years ago

And it works!!! Again, thanks for sticking with this. Very nice module!

GorboducRex commented 3 years ago

Aaaaaand... I'm back...

When I use client.get_new_messages(), I get all the messages. When I use client.get_messages() I get only the unread ones. Also, in your examples, some of them don't work. For example, message.number works as message['id'].

GorboducRex commented 3 years ago

Nope... skip the part about all vs. unread. I think that's working fine.

GorboducRex commented 3 years ago

Actually, it seems that no messages come back as unread. All messages works, but new messages does not, even when read is False.

leogomezz4t commented 3 years ago

ok so new messages doesn't use read I can't modify the textnow storage so it starts detecting new messages since the initialization of the Client instance

GorboducRex commented 3 years ago

Okay. So if I just use all messages, and go through them myself to find unread, I'll be good. Excellent. Now I just have to figure out how to mark them as read programmatically. Thanks!

leogomezz4t commented 3 years ago

Try this for a simple bot

import TNAPI as tn
client = tn.Client("email", "password")
while 1:
   msgs = client.get_new_messages()
   for msg in msgs:
         if msg.type == tn.MESSAGE_TYPE:
                if msg.content == "ping":
                        client.send_sms(msg.number, "pong")
leogomezz4t commented 3 years ago

No, the client already finds new messages programmatically

leogomezz4t commented 3 years ago

Okay. So if I just use all messages, and go through them myself to find unread, I'll be good. Excellent. Now I just have to figure out how to mark them as read programmatically. Thanks!

the read attribute from get_all_messages is the raw json from the textnow database. Read means if you read the message in the textnow app or website

GorboducRex commented 3 years ago

client.get_new_messages() isn't working for me - it returns nothing. But like I said, client.get_messages() returns everything, so I can deal with it programmatically.

leogomezz4t commented 3 years ago

On Mon, Mar 22, 2021 at 3:19 PM GorboducRex @.***> wrote:

client.get_new_messages() isn't working for me - it returns nothing. But like I said, client.get_messages() returns everything, so I can deal with it programmatically.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/leogomezz4t/PyTextNow_API/issues/11#issuecomment-804402701, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQV6RXV3STMX3NAOJCSWMVDTE6X7VANCNFSM4ZTVJQ5Q .

It depends on what you want to do get_new_messages() is works as a way to check if any new messages have been sent since the initialisation of client