Login Register




Tutorial Create your own SkypeBOT filter_list
Author
Message
Create your own SkypeBOT #1
What is Skype4Py
Skype4Py is a Python wrapper for the Skype API. It is platform independent, written completely in Python and reimplements the Skype4COM's API in a pythonic way.
This specific tutorial is written for Python 2, however it can easily be translated for Python 3. Even though this does have a lot of stuff, I will be going over what I personally use.
By the way, it says PHP code. That's because I want syntax highlighting. All this is in python. Not php.
Also, This will be a shitty bot. I feel the need to say this, because I'm covering the VERY BASICS. Learning python will help you a lot more.


Download Links
I assume you already have python when reading this, if not, Download here. Also, you will need to download Skype4Py. Anyways, that should be everything you need.

Get the bot attached to skype
First you will want your bot to attach to skype. This can be easily done with the code below.
PHP Code:
import Skype4Py

# Create an instance of the Skype class.
skype Skype4Py.Skype()

# Connect the Skype object to the Skype client.
skype.Attach() 

After that, you should get something like this
[Image: hCaja.png]

Starting with the bot
Here's a few things you should know. These are the main things I use in my bot.
I still recommend you learn the other stuff too.


Spoiler: Message.Body
PHP Code:
#Here's a short example on what you could do.

if Message.Body == '!test':
    
Message.Chat.SendMessage('Appears to work!')

#This makes it so whenever a message is "!test", it sends "Appears to work!"

#You could always do something along the lines of

if msg.startswith('!test'):
    
Message.Chat.SendMessage('Appears to work!')

#This makes it so if someone's message starts with !test, it will send. Even if it has random characters after it. 
Spoiler: Message.Chat.SendMessage
PHP Code:
#This is extremely useful. This allows the bot to send messages.
#If you need an example, view it above. 
Spoiler: Message.FromHandle
This is also very useful. Let's say you want admin controls, that only you can do. My bot has a simple leave feature, and it's set up like
PHP Code:
if Status == 'SENT' or Message.FromHandle == 'MySkypeName'#If sent by the bot, or if it's sent by me.
    
if Message.Body == '!leave'#If the command activates
    
Message.Chat.SendMessage('Buh-bye!')
    
Message.Chat.SendMessage('/leave'#Sends /leave, which happens to be a skype command 

Putting together the bot

Spoiler:
Now, I don't think you want to know everything in depth. If you do, you can check the links below.

First of all, you should import Skype4Py
PHP Code:
import Skype4Py[php]

[
color=white]Then you want skype4py to attach to your skypeHere's something you should add.[/color]
[php]
skype = Skype4Py.Skype();
skype.OnMessageStatus = command
if skype.Client.IsRunning == False:
    skype.Client.Start()
skype.Attach(); 

Then you want to set up a command, and set it up so it reads it. You then need to set up a test command, which you can see below.

PHP Code:
def command(MessageStatus):
    if 
Status == 'SENT' or (Status == 'RECEIVED'):
  if 
Message.Body == '!test':
    
Message.Chat.SendMessage('Appears to work!'

And then an endless loop (There are many ways to do this).

PHP Code:
while True:
    
raw_input(''

And then, you're all set! (I think)

Useful Links
http://python.org/
http://skype4py.sourceforge.net/doc/html/
http://sourceforge.net/projects/skype4py/

Download to my thinned-down bot (not an achievement at all):
http://db.tt/ZHBlcT3M
Spoiler:
Code:
import Skype4Py

def command(Message, Status):
    if Status == 'SENT' or (Status == 'RECEIVED'):
  if Message.Body == '!test':
    Message.Chat.SendMessage('Appears to work!')

skype = Skype4Py.Skype();
skype.OnMessageStatus = command
if skype.Client.IsRunning == False:
    skype.Client.Start()
skype.Attach();  
while True:
    raw_input('')

Reply

RE: Create your own SkypeBOT #2
Sweet this could be awesome, a Python web based skype bot.
[Image: hZbv6.gif]

Reply

RE: Create your own SkypeBOT #3
(10-14-2012, 01:59 AM)Immortal Wrote: Sweet this could be awesome, a Python web based skype bot.

It's not web based.

Reply

RE: Create your own SkypeBOT #4
Nice tutorial bro, I think it's really nice you posted this.
[Image: V8OSA.gif]

Reply

RE: Create your own SkypeBOT #5
(10-14-2012, 03:37 AM)BaneKitty Wrote: Nice tutorial bro, I think it's really nice you posted this.

Thanks. I had a lot of fun making this, so I'm sure other people will too.

Reply

RE: Create your own SkypeBOT #6
The amount of spam this caused in group chat was terrible. Tongue
[Image: 7ajmN5P.jpg]

Discord: Oni#6099
Skype: oni_sl
Telegram: oni_sl (Add)
Steam: Oni (Add)

Reply

RE: Create your own SkypeBOT #7
this is sweet, but the api is pretty buggy. :F
but I made a skype bot that resolved ip's and booted users :F
[Image: hZbv6.gif]

Reply

RE: Create your own SkypeBOT #8
Loving the tutorial layout!
Good job!

- Daaksin
[Image: IYvpz.gif]

Reply

RE: Create your own SkypeBOT #9
Very good tutorial started to love this forum Smile

Reply

RE: Create your own SkypeBOT #10
Very detailed tutorial, thanks for the share.

Reply






Users browsing this thread: 1 Guest(s)