2

I've tried so many ways the past week or so to try to get this to work. I've managed to get Skype2IRC to work in another script, and not spam IRC or anything. It was good. Just on message status, send message to IRC. That part I can get down easily. However, the part going from IRC to Skype is where I'm having issues. First, I figured I'd try to get it to work with multi-threading. Didn't go out well. Then, I tried this;

import os,sys,time,Skype4Py,socket,re,string
from random import choice
s = Skype4Py.Skype()
s.Attach() #Attach to Skype. Make sure to accept permissions from Skype client!
name = "Ibex"
network = "irc.myserver.net"
channel = "#Skype"
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
print irc.recv ( 4096 )
irc.send ( 'NICK '+name+'\r\n' )
irc.send ( 'USER '+name+' '+name+' '+name+' : IRC Bot\r\n' )
irc.send ( 'JOIN '+channel+'\r\n' )
ircusername = '' #referencing variable so it can be used before, data will change in while loop
ircmessage = '' #same as above
def Ibex(Message, Status):
    chat = Message.Chat
    members = chat.MemberObjects
    msg = Message.Body
    send = Message.Chat.SendMessage
    sAlias = Message.FromDisplayName
    sUsername = Message.FromHandle
    if Status == 'RECEIVED':
        irc.send ( 'PRIVMSG '+channel+' :<Skype - '+sUsername+'>: '+msg+'\r\n' )
    if ircusername != '':
        try:
            ircmessage = data.split(channel+" :",1)[1]
            send("<IRC - "+ircusername+">: "+ircmessage)
        except:
            print "Error getting new IRC message."
s.OnMessageStatus = Ibex
while True:
    data = irc.recv ( 4096 )
    print data
    if data.find ( 'PING' ) != -1:
        irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
    if data.find ( 'KICK' ) != -1:
        irc.send ( 'JOIN '+channel+'\r\n' )
    try:
        ircusername = re.search(':(.*)!', data)
        ircusername = ircusername.group(1)
    except:
        pass

After tons of trial and error. And, a LOT of spam in IRC and Skype, I managed to get this to send IRC messages to skype. HOWEVER, it spams.

I'll send a message in IRC, and nothing will happen. I'll send a message in Skype (hence s.OnMessageStatus = Ibex) and it sends the IRC message, as expected. However, it won't stop sending it. It spams it like crazy. I tried doing something like setting a sendMSG = True when a message is received, and setting sendMSG to false after sending it, then if sendMSG = true, then send. That didn't seem to work out well.

Anyone have any suggestions? Am I just missing something small causing this error? Thanks to anyone in advanced, this has been bothering me for a while now.

I managed to get an old IRC/Skype bridge to work a while ago, but that script is long gone and I can't remember exactly how I did it.

Wooble
  • 87,717
  • 12
  • 108
  • 131
Axiom
  • 902
  • 1
  • 10
  • 23
  • Chat via 3rd part applications in skype is deprecated [source](http://blogs.skype.com/2013/11/06/feature-evolution-and-support-for-the-skype-desktop-api/) – M4rtini Jan 20 '15 at 04:07
  • I know this, I have an older version of Skype installed and my Skype command bot, etc. work perfectly fine with it. My issue is that something I'm doing is causing the bot to spam Skype, instead of sending messages from IRC as they come through. I can get messages to send/receive/do whatever with in Skype using the Skype4Py module without any issues. – Axiom Jan 20 '15 at 04:29
  • I see the example folder of Skype4Py have a skypebot example. They seem to call `Message.MarkAsSeen()`. I have no way of testing this really. But that might work. – M4rtini Jan 20 '15 at 04:37

0 Answers0