Last active
September 8, 2015 18:27
-
-
Save vpetersson/34006e5f4b81fa469ce9 to your computer and use it in GitHub Desktop.
Infinite loop to call Lufthansa's customer service line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Skype4Py | |
import random | |
from time import sleep | |
""" | |
A script to keep recalling Lufthansa's customer support until you get through. | |
You will need Skype4Py installed. I couldn't get it working on Mac OS X, so had | |
run it in an Ubuntu 14.04 VM. | |
Code borrowed from: | |
https://askubuntu.com/questions/5284/how-to-call-a-number-from-command-line-with-skype | |
""" | |
LUFTHANSA = [ | |
'+443719459747', # UK | |
'+46770111010', # Sweden | |
'+496986799799', # Germany | |
'+18006453880', # US | |
'+18005635954', # Canada | |
'+4570100333', # Denmark | |
] | |
ATTEMPT = 0 | |
# This variable will get its actual value in OnCall handler | |
CallStatus = None | |
# Here we define a set of call statuses that indicate a call has been either aborted or finished | |
CallIsFinished = set([ | |
Skype4Py.clsFailed, | |
Skype4Py.clsFinished, | |
Skype4Py.clsMissed, | |
Skype4Py.clsRefused, | |
Skype4Py.clsBusy, | |
Skype4Py.clsCancelled]) | |
def AttachmentStatusText(status): | |
return skype.Convert.AttachmentStatusToText(status) | |
def CallStatusText(status): | |
return skype.Convert.CallStatusToText(status) | |
# This handler is fired when status of Call object has changed | |
def OnCall(call, status): | |
global CallStatus | |
CallStatus = status | |
print 'Call status: {}'.format(CallStatusText(status)) | |
# This handler is fired when Skype attatchment status changes | |
def OnAttach(status): | |
print 'API attachment status: {}'.format(AttachmentStatusText(status)) | |
if status == Skype4Py.apiAttachAvailable: | |
skype.Attach() | |
# Creating Skype object and assigning event handlers.. | |
skype = Skype4Py.Skype() | |
skype.OnAttachmentStatus = OnAttach | |
skype.OnCallStatus = OnCall | |
# Starting Skype if it's not running already.. | |
if not skype.Client.IsRunning: | |
print 'Starting Skype..' | |
skype.Client.Start() | |
# Attatching to Skype.. | |
print 'Connecting to Skype..' | |
skype.Attach() | |
# We *really* want to go through, so let's fire up an infinite loop. | |
while True: | |
# Pick a random call center | |
CALL_PICK = random.choice(LUFTHANSA) | |
# Make the call | |
print 'Calling {}. (attempt {})'.format(CALL_PICK, ATTEMPT) | |
try: | |
skype.PlaceCall(CALL_PICK) | |
ATTEMPT += 1 | |
except: | |
sleep(1) | |
# Loop until CallStatus gets one of "call terminated" values in OnCall handler | |
while not CallStatus in CallIsFinished: | |
pass | |
print 'Going to sleep for 15 seconds...' | |
sleep(15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment