Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def OnBlipSubmitted(properties, context):
- blip = context.GetBlipById(properties['blipId'])
- doc = blip.GetDocument()
- text = doc.GetText()
- bitlied = []
- for ann in blip.annotations:
- logging.info('ann.name:'+ann.name + ' ann.value:'+ann.value)
- if ann.name == 'link/auto' and reBitly.match(ann.value):
- bitlied.append((ann.range.start, ann.range.end, ann.value))
- for start, end, value in bitlied:
- url = bitly(value)
- if url:
- payload = text[start:end]
- logging.info('payload:'+payload+' value:'+value+ ' link to:'+url)
- range = document.Range(start, end)
- doc.DeleteAnnotationsInRange(range, 'link/auto')
- doc.SetAnnotation(range, 'link/manual', url)
- doc.AppendText(value+' was unbit.lied ;-)')
Add Comment
Please, Sign In to add comment