diff options
-rw-r--r-- | skype/skyped.py | 23 | ||||
-rw-r--r-- | skype/t/irssi/skype-call.test | 13 |
2 files changed, 34 insertions, 2 deletions
diff --git a/skype/skyped.py b/skype/skyped.py index 8ce35777..f15245ed 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -37,9 +37,12 @@ import ssl __version__ = "0.1.1" def eh(type, value, tb): + global options + if type != KeyboardInterrupt: print_exception(type, value, tb) gobject.MainLoop().quit() + options.conn.close() # shut down client if it's running try: skype.skype.Client.Shutdown() @@ -74,11 +77,26 @@ def skype_idle_handler(skype): dprint("Warning, pinging Skype failed (%s)." % (s)) return True +def send(sock, txt): + from time import sleep + count = 1 + done = False + while (not done) and (count < 10): + try: + sock.send(txt) + done = True + except Exception, s: + count += 1 + dprint("Warning, sending '%s' failed (%s). count=%d" % (txt, s, count)) + sleep(1) + if not done: + options.conn.close() + def bitlbee_idle_handler(skype): if options.conn: try: e = "PING" - options.conn.send("%s\n" % e) + send(options.conn, "%s\n" % e) except Exception, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) options.conn.close() @@ -136,6 +154,7 @@ def dprint(msg): if options.debug: print now + ": " + msg + sys.stdout.flush() if options.log: sock = open(options.log, "a") sock.write("%s: %s\n" % (now, msg)) @@ -171,7 +190,7 @@ class SkypeApi: dprint('<< ' + e) if options.conn: try: - options.conn.send(e + "\n") + send(options.conn, e + "\n") except Exception, s: dprint("Warning, sending '%s' failed (%s)." % (e, s)) options.conn.close() diff --git a/skype/t/irssi/skype-call.test b/skype/t/irssi/skype-call.test new file mode 100644 index 00000000..8f502a59 --- /dev/null +++ b/skype/t/irssi/skype-call.test @@ -0,0 +1,13 @@ +TESTNEEDEDVARS="TEST_SKYPE_ID TEST_SKYPE_PASSWORD" +TESTDURATION=60 +TESTCHECKRESULT="grep '\[Test Passed\]' status.log" +TESTLOGIN="$TEST_SKYPE_ID" +TESTPASSWORD="$TEST_SKYPE_PASSWORD" +### Test receiving call output +/expectbee 'Welcome to the BitlBee' -command 'msg $$C register testing' +/expectbee 'Account successfully created' -command 'msg $$C account add skype @LOGIN@ @PASSWORD@' +/expectbee 'Account successfully added' -command 'msg $$C account 0 set test_join true' +/expectbee 'test_join' -command 'msg $$C account 0 on' +/expectjoin echo123 -command 'ctcp echo123 call' +/expectbee 'You are currently ringing the user' -command 'ctcp echo123 hangup' +/expectbee '(You cancelled the call|You finished the call)' -command 'quit Test Passed' |