I'm trying to write a small skype bot who will block some users.
This is the code I have:
import Skype4Py
skype = Skype4Py.Skype(Transport='x11')
skype.Attach()
print "Attachment status is " + str(skype.AttachmentStatus)
...
user._SetIsBlocked(True)
First time I run this script it gives me 1 as skype.AttachmentStatus, and blocks the user I picked. But If I run it second time, it will give me 0 as skype.AttachmentStatus, and will not block the user I picked.
If I'll wait some time(about 5 min) and then try to run script again, it starts to work. But only once. I'll have to wait another five minutes to run it again.
Can somebody help or explain why this is happening?
Thanks!
Solution to this error is to add your own event handlers to skype.OnAttachmentStatus
Example:
# Attachment status handler
def OnAttach(status):
print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status)
if status == Skype4Py.apiAttachAvailable:
skype.Attach()
if status == Skype4Py.apiAttachSuccess:
print '*************************************************'
...
# Creating Skype object, assigning handler functions and attaching to Skype
skype = Skype4Py.Skype(Transport='x11')
skype.OnAttachmentStatus = OnAttach
skype.OnMessageStatus = OnMessageStatus
After that it will work every time you run it.