Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from skpy import Skype, SkypeNewMessageEvent, SkypeEventLoop, SkypeMsg
- import pdb
- import os
- #enter the following credentials in terminal
- #import os,
- #os.environ['USERNAME']='<your skype username here>'
- #os.environ['PASSWORD']='<your skype password here>'
- username=os.environ.get('USERNAME')
- password=os.environ.get('PASSWORD')
- recipient='lovingthebreeze'
- sk=Skype(username,password)
- sk.user
- sk.contacts
- ch=sk.contacts[recipient].chat
- def write_message(message):
- return ch.sendMsg(SkypeMsg.bold('['+username+'] ')+message)
- """
- Writes the received username and message to the skype chatroom.
- example inputs:
- username = 'Alice'
- message = 'hello from Alice!'
- written to chatroom:
- [Alice] hello from Alice!
- """
- #raise NotImplementedError
- write_message('yo, can u see this message? im using a bot to write you')
- class SkypePing(SkypeEventLoop):
- def __init__(self):
- super(SkypePing,self).__init__(username,password)
- def onEvent(self,event):
- if isinstance(event,SkypeNewMessageEvent):
- print(event.msg.userId,':',event.msg.content)
- """
- Returns a list of any new messages found.
- :rtype: List[Message]
- """
- #raise NotImplementedError
- sk=SkypePing()
- sk.loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement