Post: [Python] Skype bot template
10-12-2015, 04:40 AM #1
Python
Bebe Snek
(adsbygoogle = window.adsbygoogle || []).push({}); Enjoy Happy

    #Import Dependencies
import Skype4Py,os,urllib2

#The tag for the bot
tag = "[Weeb]: "
sk = Skype4Py.Skype() #Create Skype Instance
print "Please allow access to Python.exe from Skype client" #Let user know to allow access
sk.Attach() #Attach and request access if not already authorized
os.system('cls'Winky Winky #Clear Screen (This runs simple command prompt commands)
os.system('title Skype bot!'Winky Winky #Change title of console window
print "Bot Started!" #Let user know the bot started

#Define the function for the bot, Skype passes in the message info and status info
def weeb(Message,Status):
chat = Message.Chat #Get the chat object the message was sent in
msg = Message.Body #Get the actual message text itself
send = Message.Chat.SendMessage #Function to send message back to that chat
senderDisplay = Message.FromDisplayName #Display name of the sender
senderHandle = Message.FromHandle #Skype username itself

#If the message was sent by you or received from someone else
if Status == "SENT" or Status == "RECEIVED":
#If the message text is exactly !ping
if msg == "!ping":
send(tag+"Pong! Hi, "+senderDisplay+"!")

#If the message starts with "!say " (With the space)
if msg.startswith("!say "):
#Get the text after "!say " by replacing "!say " with "" (nothing)
sayText = msg.replace("!say ","")
#Call the bot function to get it to run
sk.OnMessageStatus = weeb

#Create a while loop that doesn't do anything to make sure the bot stays open
while True:
raw_input(''Winky Winky

The following user thanked Python for this useful post:

EncepT

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo