Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

KeyError in SkypeEventLoop when a new contact sends a message #213

Description

@martintaleski

I am using the event example from the README, using the SkypeEventLoop.

When a new user that is not in my contact list writes me, the program crashes. The trackback is at the bottom of this report.

When I start the script again, it works as expected.

Account type

Live Account, created several days ago

Conversation details

1:1 chat with a new (not approved) contact

Steps to reproduce

Run the following script, and write to Skype account from a new, previously unapproved contact.

In order to test it, so you don't need to create an account, you can delete the contact (Right click on the Contact > Profile > Delete Contact ), and afterwards delete the conversation, and restart the script.

from skpy import SkypeEventLoop, SkypeNewMessageEvent

username = 'your@email'
password = 'your password'

class SkypePing(SkypeEventLoop):
    def onEvent(self, event):
        # return if it is not an MessageEvent
        if not isinstance(event, SkypeNewMessageEvent):
            return
        
        # return if it is my own message
        if event.msg.userId == self.userId:
            return

        print(event.msg.chat)

        if "ping" in event.msg.content.lower():
            event.msg.chat.sendMsg("Pong!")

if __name__ == "__main__":
    sk = SkypePing(username, password, autoAck=True)
    sk.loop()

Result or traceback

{{---skype-id---}} is the Skype ID of the sender account, removed from the traceback for privacy issues

The program crashes with the following error
Traceback (most recent call last):
  File "/home/martin/work/venv/skype_test/lib/python3.10/site-packages/skpy/chat.py", line 457, in __getitem__
    return super(SkypeChats, self).__getitem__(key)
  File "/home/martin/work/venv/skype_test/lib/python3.10/site-packages/skpy/core.py", line 138, in __getitem__
    return self.cache[key]
KeyError: '8:${{---skype-id---}}'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions