Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Skype4Py
- import sys, cmd, time
- client = Skype4Py.Skype()
- class bcolors:
- HEADER = '\033[95m'
- OKBLUE = '\033[94m'
- OKGREEN = '\033[92m'
- WARNING = '\033[93m'
- FAIL = '\033[91m'
- ENDC = '\033[0m'
- BOLD = '\033[1m'
- UNDERLINE = '\033[4m'
- def cmnd(line, dct):
- for n, item in enumerate(dct):
- print ('\t{} {}'.format(n, item))
- for inp in iter(lambda: input('> '), None):
- for n, item in enumerate(dct):
- if inp == n:
- return item
- def hi():
- print "Hello world!"
- def cheese():
- print "It's delicious!"
- def vername(user):
- for f in client.Friends:
- if f.Handle == user:
- return True
- return False
- def msg():
- user = raw_input(">To whom? ")
- text = raw_input(">What do you want to say? ")
- if vername(user):
- client.SendMessage(user, text)
- def stringchecker():
- stri = raw_input(bcolors.OKGREEN + '[>]' + bcolors.ENDC + 'Enter a string to check for: ')
- txt = raw_input(bcolors.OKGREEN + '[>]' + bcolors.ENDC + 'Enter a text to reply: ')
- def OnMessageStatus(Message, Status):
- if Status == 'RECEIVED' or 'READ':
- if Message.Body.lower() == stri:
- client.SendMessage(Message.FromHandle, txt)
- client.OnMessageStatus = OnMessageStatus
- def botfuncs():
- def OnMessageStatus(Message, Status):
- if Status == 'RECEIVED':
- c = Message.Body
- if Message.Body.lower() == "time":
- client.SendMessage(Message.FromHandle, "The current time is {0}".format(time.strftime("%Y, %b %d, %H:%M:%S.")))
- elif c[0:4].lower() == "sudo":
- client.SendMessage(Message.FromHandle, c[5:])
- client.OnMessageStatus = OnMessageStatus
- client.Attach()
- commands = {
- 'sayhi' : hi,
- 'cheese' : cheese,
- 'msg' : msg,
- 'stringchecker' : stringchecker,
- 'botfuncs' : botfuncs
- }
- while True:
- try:
- a = cmnd("Enter a number to execute the command.", commands)
- commands[a]()
- except Exception as e:
- print e
- print "That's not the correct usage."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement