Esempio n. 1
0
 def process_removegirl(self, update, command, params):
     params = params.replace(" ", "").lower()
     chat_id = update.message.chat_id
     self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
     girls = list(Girl.select(Girl.username == params))
     if girls:
         girls[0].delete_instance()
     self.bot.sendMessage(chat_id=chat_id, text="Removed girl '%s'" % params)
Esempio n. 2
0
 def process_girl(self, update, command, params):
     girls = list(Girl.select())
     chat_id = update.message.chat_id
     if girls:
         self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.UPLOAD_PHOTO)
         girl = random.choice(girls)
         media = self.instagram.load_user_feed(girl.user_id, count=50)
         media = random.choice(media)
         image_url = media.images["standard_resolution"].url
         self.bot.sendPhoto(chat_id=chat_id, photo=image_url, caption=self.instagram.get_user_page(girl.username))
     else:
         self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
         self.bot.sendMessage(chat_id=chat_id, text="No girls(")
Esempio n. 3
0
    def parse_item(self,item):
        name = item.xpath("div[@class='user-info']/h3/a")[0].text
        twitter = item.xpath("div[@class='user-info']/h3/span/a")[0].text
  

        avators = item.xpath("div[@class='photo-link-outer']/a/img//@src")

        with db_session:
            girl = Girl.get(twitter=twitter)
            if girl is None:
                girl = Girl(name=name,twitter=twitter)
            else:
                girl.name = name
            commit()
            for avator in avators:
                photo = Photo.get(link=avator)
                if photo is None:
                    try:
                        local = crawl_photo(avator)
                        photo = Photo(uid=girl.id,link=avator,local=local)
                        commit()
                    except requests.exceptions.ConnectionError:
                        pass
Esempio n. 4
0
 def process_addgirl(self, update, command, params):
     chat_id = update.message.chat_id
     params = params.replace(" ", "").lower()
     girl, created = Girl.get_or_create(username=params)
     self.bot.sendChatAction(chat_id=chat_id, action=telegram.ChatAction.TYPING)
     if not created:
         self.bot.sendMessage(chat_id=chat_id, text="Girl '%s' already exists" % params)
     else:
         instagram_user = self.instagram.get_user_by_username(params)
         if instagram_user and self.instagram.load_user_feed(instagram_user.id, count=1) is not None:
             girl.user_id = instagram_user.id
             girl.save()
             self.bot.sendMessage(chat_id=chat_id, text="Added girl '%s'" % params)
         else:
             girl.delete_instance()
             self.bot.sendMessage(chat_id=chat_id, text="Cannot add this girl(" % params)