JMW JMW - 1 year ago 99
Python Question

need an python script that uses skype4py to send an instant message

i've installed skype4py. ( )

i don't know python. i need a simple example script, that takes the first cmd argument as username and the second argument as message. this instant message should then be sent to the skype username.

does anyone know how to do this?

thanks a lot in advance

Answer Source

Should work based on the docs.

from Skype4Py import Skype
import sys

client = Skype()
user = sys.argv[1]
message = ' '.join(sys.argv[2:]
client.SendMessage(user, message)


$ python someuser This is my message

You better not use this to spam people :D

If you need to do anything further with this, you better learn Python. For educational purposes, here's a line by line breakdown:

  1. Import class Skype from Skype4Py
  2. Import sys, which contains the arguments the script was passed from the command line in a list of strings, argv
  3. Create an instance of Skype, call it client
  4. Attach client to the user's Skype client
  5. Set the user to send it to to the second command line argument (first is the script name)
  6. Construct a string (the message) by joining each string in command line arguments after the 3rd (sys.argv[2:]), using a space as a separator
  7. Send the message to the user
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download