daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Jun 18th, 2017 4,322 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from skpy import Skype, SkypeNewMessageEvent, SkypeEventLoop, SkypeMsg
  2. import pdb
  3. import os
  4.  
  5. #enter the following credentials in terminal
  6. #import os,
  7. #os.environ['USERNAME']='<your skype username here>'
  8. #os.environ['PASSWORD']='<your skype password here>'
  9. username=os.environ.get('USERNAME')
  10. password=os.environ.get('PASSWORD')
  11. recipient='lovingthebreeze'
  12.  
  13. sk=Skype(username,password)
  14. sk.user
  15. sk.contacts
  16. ch=sk.contacts[recipient].chat
  17.  
  18.  
  19. def write_message(message):
  20.  
  21.     return ch.sendMsg(SkypeMsg.bold('['+username+']  ')+message)
  22.     """
  23.    Writes the received username and message to the skype chatroom.
  24.  
  25.    example inputs:
  26.    username = 'Alice'
  27.    message = 'hello from Alice!'
  28.  
  29.    written to chatroom:
  30.    [Alice] hello from Alice!
  31.    """
  32.         #raise NotImplementedError
  33.  
  34. write_message('yo, can u see this message? im using a bot to write you')
  35.  
  36. class SkypePing(SkypeEventLoop):
  37.     def __init__(self):
  38.         super(SkypePing,self).__init__(username,password)
  39.     def onEvent(self,event):
  40.         if isinstance(event,SkypeNewMessageEvent):
  41.             print(event.msg.userId,':',event.msg.content)
  42.     """
  43.    Returns a list of any new messages found.
  44.  
  45.    :rtype: List[Message]
  46.    """
  47.     #raise NotImplementedError
  48.  
  49. sk=SkypePing()
  50. sk.loop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top