Changes in / [35571fb:4cb21b7]
- Files:
-
- 10 added
- 9 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/AUTHORS
r35571fb r4cb21b7 7 7 Other contributors: 8 8 9 Miklos Vajna <vmiklos@ vmiklos.hu>9 Miklos Vajna <vmiklos@frugalware.org> 10 10 Skype module 11 11 -
protocols/skype/HACKING
r35571fb r4cb21b7 17 17 18 18 4) irssi 19 20 == Tests21 22 The plugin is tested with a mocked IRC client and a mocked skyped. To add a new23 test, the following steps are necessary:24 25 1) Add a new -skyped.mock file: just do the test manually, copy&paste the26 skyped output and clean it up, so Alice talks to Bob. You can test the created27 mock file by starting skyped with the -m option, and testing it from an IRC28 client manually.29 30 2) Add a new -bitlbee.mock file: do the test manually from irssi, and use:31 32 /connect -rawlog rawlog localhost33 34 Then clean up the rawlog: the input lines are parsed as matching patterns, so35 boring prefix/suffix text can be left out, non-interesting lines can be36 deleted. The output lines still have to be strict IRC commands, as usual.37 38 3) Add the new test to test.py and run it!39 40 // vim: ft=asciidoc -
protocols/skype/Makefile
r35571fb r4cb21b7 24 24 25 25 test: all 26 ./test.py26 $(MAKE) -C t/ all 27 27 28 28 doc: $(MANPAGES) -
protocols/skype/skype.c
r35571fb r4cb21b7 2 2 * skype.c - Skype plugin for BitlBee 3 3 * 4 * Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@ vmiklos.hu>4 * Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@frugalware.org> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify -
protocols/skype/skyped.py
r35571fb r4cb21b7 3 3 # skyped.py 4 4 # 5 # Copyright (c) 2007 -2013 by Miklos Vajna <vmiklos@vmiklos.hu>5 # Copyright (c) 2007, 2008, 2009, 2010, 2011 by Miklos Vajna <vmiklos@frugalware.org> 6 6 # 7 7 # This program is free software; you can redistribute it and/or modify … … 276 276 sock.close() 277 277 278 class MockedSkype:279 """Mock class for Skype4Py.Skype(), in case the -m option is used."""280 def __init__(self, mock):281 sock = open(mock)282 self.lines = sock.readlines()283 284 def SendCommand(self, c):285 pass286 287 def Command(self, msg, Block):288 if msg == "PING":289 return ["PONG"]290 line = self.lines[0].strip()291 if not line.startswith(">> "):292 raise Exception("Corrupted mock input")293 line = line[3:]294 if line != msg:295 raise Exception("'%s' != '%s'" % (line, msg))296 self.lines = self.lines[1:] # drop the expected incoming line297 ret = []298 while True:299 # and now send back all the following lines, up to the next expected incoming line300 if len(self.lines) == 0:301 break302 if self.lines[0].startswith(">> "):303 break304 if not self.lines[0].startswith("<< "):305 raise Exception("Corrupted mock input")306 ret.append(self.lines[0][3:].strip())307 self.lines = self.lines[1:]308 return ret309 310 278 class SkypeApi: 311 def __init__(self, mock): 312 if not mock: 313 self.skype = Skype4Py.Skype() 314 self.skype.OnNotify = self.recv 315 self.skype.Client.Start() 316 else: 317 self.skype = MockedSkype(mock) 279 def __init__(self): 280 self.skype = Skype4Py.Skype() 281 self.skype.OnNotify = self.recv 282 self.skype.Client.Start() 318 283 319 284 def recv(self, msg_text): … … 370 335 c = self.skype.Command(e, Block=True) 371 336 self.skype.SendCommand(c) 372 if hasattr(c, "Reply"): 373 self.recv(c.Reply) # Skype4Py answer 374 else: 375 for i in c: # mock may return multiple iterable answers 376 self.recv(i) 337 self.recv(c.Reply) 377 338 except Skype4Py.SkypeError: 378 339 pass … … 399 360 # this will be read first by the input handler 400 361 self.buf = None 401 self.mock = None402 362 403 363 … … 462 422 options = Options() 463 423 try: 464 opts, args = getopt.getopt(sys.argv[1:], "c:dhH:l: m:np:v", ["config=", "debug", "help", "host=", "log=", "mock=", "nofork", "port=", "version"])424 opts, args = getopt.getopt(sys.argv[1:], "c:dhH:l:np:v", ["config=", "debug", "help", "host=", "log=", "nofork", "port=", "version"]) 465 425 except getopt.GetoptError: 466 426 options.usage(1) … … 476 436 elif opt in ("-l", "--log"): 477 437 options.log = arg 478 elif opt in ("-m", "--mock"):479 options.mock = arg480 438 elif opt in ("-n", "--nofork"): 481 439 options.daemon = False … … 528 486 server(options.host, options.port) 529 487 try: 530 skype = SkypeApi( options.mock)488 skype = SkypeApi() 531 489 except Skype4Py.SkypeAPIError, s: 532 490 sys.exit("%s. Are you sure you have started Skype?" % s) -
protocols/skype/skyped.txt
r35571fb r4cb21b7 39 39 Set the log file in background mode (default: none) 40 40 41 -m, --mock=<file>::42 Mock mode: replay session from file, instead of connecting to Skype.43 44 41 -n, --nofork:: 45 42 Don't run as daemon in the background … … 53 50 == AUTHOR 54 51 55 Written by Miklos Vajna <vmiklos@ vmiklos.hu>52 Written by Miklos Vajna <vmiklos@frugalware.org>
Note: See TracChangeset
for help on using the changeset viewer.