Terrance / SkPy

An unofficial Python library for interacting with the Skype HTTP API.
https://skpy.t.allofti.me
BSD 3-Clause "New" or "Revised" License
268 stars 66 forks source link

How to join a group using Join URL and send message? #221

Open JafferWilson opened 1 year ago

JafferWilson commented 1 year ago

Here is the example:


username            = "email@gmail.com"
password            = "password"
SANDBOX_MODE        = True

sandboxchatgrpUrl   = [
                        "https://join.skype.com/pscCsBHhcGAJ",
                      ]
from skpy import Skype

SKPY_DEBUG_HTTP = 1
slogin      = Skype(username, password)

print("Skype Login Successful.....!")

try:
    if SANDBOX_MODE == True:
        response    = [slogin.chats.urlToIds(urls) for urls in sandboxchatgrpUrl]
except Exception as e:
    print("It seems like you are not the member of this Group.")
    print(e)
    sys.exit()
Messenger   = [slogin.chats[resp["id"]] for resp in response]

I am trying to send message to the group but it is not getting successful and gives me error. I think just because I am not joined with the group it is giving error. Once I join the group manually then it send message without any issues. Please take a look at the example and let me know. Here is the error:

Skype Login Successful.....!
Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\skpy\chat.py", line 457, in __getitem__
    return super(SkypeChats, self).__getitem__(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\skpy\core.py", line 138, in __getitem__
    return self.cache[key]
           ~~~~~~~~~~^^^^^
KeyError: '19:gibberrish@thread.skype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\AIMS-RESEARCH\PycharmProjects\pythonProject\main.py", line 31, in <module>
    Messenger   = [slogin.chats[resp["id"]] for resp in response]
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AIMS-RESEARCH\PycharmProjects\pythonProject\main.py", line 31, in <listcomp>
    Messenger   = [slogin.chats[resp["id"]] for resp in response]
                   ~~~~~~~~~~~~^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\skpy\chat.py", line 459, in __getitem__
    return self.chat(key)
           ^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\skpy\chat.py", line 491, in chat
    json = self.skype.conn("GET", "{0}/users/ME/conversations/{1}".format(self.skype.conn.msgsHost, id),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\skpy\conn.py", line 237, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('404 response from GET https://azwcus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:gibberrish@thread.skype', <Response [404]>)
JafferWilson commented 1 year ago

Please help me send the messages to the existing group efficiently.

Terrance commented 1 year ago

Currently you can authenticate as a guest with a join URL, which will allow you to interact with a single chat without a Skype account (see the end of Logging in in the docs).

I'm not sure how joining additional chats via a link works when you're already signed in, but if you can find the request in your browser that does it when using Skype for Web then it can probably be replicated.

JafferWilson commented 1 year ago

I see the guest login part now. But what if I wanted to join not as a guest but a member? If there a way. I was able to extract the group id but failed to make a connection and send message to the existing group. One of my friend send the link to me on my mobile through whatsapp and not through Skype. So I think there has to be a way out to join a group through URL if the request is forwarded to you. Manually, I got success through searching for the URL on web. Then it directly says open chat which indicates I have joined the conversation and can send message. After that I can also send message through the Skpy message send function. But when I did not follow the manual procedure, it is giving me the above error as you see. Please let me know how I can join a conversation if I am not in the group already without being a guest user. If you need any further clarification, please let me know I will do whatever I can to explain it. But I hope that you have got the problem.

Terrance commented 1 year ago

As noted above, joining through URLs outside of authenticating as a guest isn't currently implemented, and would require capturing the request your browser is making to do that join.

JafferWilson commented 1 year ago

Okay means I have to wait to get what I wanted to achieve. I have tried your way as a guest it was working fine for me but it does not give the profile of the message sender since it is a guest. But will do. Still I will wait for the group joining without being a guest. I hope you have any idea to update the project.

islisong commented 1 year ago

Is this problem solved, I also encountered it now