@@ -0,0 +1,1528 @@
+# !/usr/bin/python%0A# -*- coding: utf-8 -*-%0A# pylint: disable = C1001%0A# pylint: disable = C0111%0A# pylint: disable = C0103%0A# pylint: disable = W0703%0A# pylint: disable = C0301%0A%0Aimport urllib2%0Aimport json%0Afrom bots.abcbot import ABCBot%0A%0Aclass BingWallpaperBot(ABCBot):%0A    BINGURL = 'http://bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&nc=1439260838289&pid=hp&video=1'%0A%0A    def __init__(self, logger, bearer):%0A        super(BingWallpaperBot, self).__init__(logger, bearer)%0A%0A    def webhookRequest(self, request):%0A        webhook = json.loads(request.body)%0A        content = self.getMessageContent(webhook%5B'data'%5D%5B'id'%5D)%0A        content = json.load(content)%0A        if 'tianjie%5C's' in content.get('text', 'bingwallpaper').lower():%0A            items = content.get('text').split()%0A            if len(items) == 2 and items%5B1%5D == u'':%0A                self.sendBingImage(webhook%5B'data'%5D%5B'roomId'%5D)%0A        elif u'bingwallpaper' in content.get('text', '').lower():%0A            self.sendBingImage(webhook%5B'data'%5D%5B'roomId'%5D)%0A%0A    def getBingImageUrl(self):%0A        url = None%0A        try:%0A            request = urllib2.Request(self.BINGURL)%0A            response = urllib2.urlopen(request)%0A            content = response.read()%0A            result = json.loads(content)%0A            url = result%5B'images'%5D%5B0%5D%5B'url'%5D%0A            self.logger(url)%0A        except Exception as e:%0A            self.logger(e.message)%0A        return url%0A%0A    def sendBingImage(self, roomId):%0A        url = self.getBingImageUrl()%0A        self.postFile(roomId, url)%0A

Add BingWallpaper