Guest User

Untitled

a guest
May 16th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. def OnBlipSubmitted(properties, context):
  2. blip = context.GetBlipById(properties['blipId'])
  3. doc = blip.GetDocument()
  4. text = doc.GetText()
  5. bitlied = []
  6. for ann in blip.annotations:
  7. logging.info('ann.name:'+ann.name + ' ann.value:'+ann.value)
  8. if ann.name == 'link/auto' and reBitly.match(ann.value):
  9. bitlied.append((ann.range.start, ann.range.end, ann.value))
  10.  
  11. for start, end, value in bitlied:
  12. url = bitly(value)
  13. if url:
  14. payload = text[start:end]
  15. logging.info('payload:'+payload+' value:'+value+ ' link to:'+url)
  16. range = document.Range(start, end)
  17. doc.DeleteAnnotationsInRange(range, 'link/auto')
  18. doc.SetAnnotation(range, 'link/manual', url)
  19. doc.AppendText(value+' was unbit.lied ;-)')
Add Comment
Please, Sign In to add comment