Пример #1
0
def main():
    config = configparser.ConfigParser()  # Don't mix it up with settings
    config.read(str(
        settings['config_file']))  # Config file stores confidential data

    data_obj = get_images(config=config)
    objsplit = merge_pictures.items_split(items_list=data_obj,
                                          number=settings['images_in_row'])
    rowimgs = merge_pictures.imgs_to_rows(img_list=objsplit, settings=settings)
    final_image = merge_pictures.rows_to_final(settings=settings, rows=rowimgs)

    now_names = [str(x.name) for x in data_obj]
    stored_names = image.get_stored_backup(settings=settings)

    image_updated = image.image_changed(now_data=now_names,
                                        stored_data=stored_names)

    if image_updated:
        print("Shop image updated.")
        image.save_image(settings=settings, image=final_image,
                         names=now_names)  # Save final image to backups
        telegram.send_image(config=config,
                            image=final_image)  # Send final image via Telegram
    elif not image_updated:
        print("Same image.")

    for shopobj in data_obj:
        if shopobj.video:
            print(f"A video for \"{shopobj.name}\" was found.")
            telegram.send_video(config=config, vid_path=shopobj.video)
Пример #2
0
 def call(self, chat, author, q):
     if self.google_search_key is None:
         self.google_search_key = db.get_key('google_search')
     data = {
         'key': self.google_search_key,
         'cx': '009373417816394415455:i3e_omr58us',
         'q': q.encode('utf-8'),
         'searchType': 'image',
         'num': 1
     }
     response = urlfetch.fetch(
         url='https://www.googleapis.com/customsearch/v1?' +
         urllib.urlencode(data),
         method=urlfetch.GET)
     items = json.loads(response.content)['items']
     if len(items) == 0:
         telegram.send(chat, "Nothing found")
         return
     image = items[0]
     image_url = image['link']
     image_response = urlfetch.fetch(image_url, method=urlfetch.GET)
     if image_response.status_code != 200:
         telegram.send(chat, "Error retrieving image")
         return
     image_name = urlparse.urlsplit(image_url).path.split('/')[-1]
     telegram.send_image(chat, image_response.content, image_name,
                         image['mime'])
Пример #3
0
    def call(self, chat, author, q):
        if q in self.cache:
            (items, offset) = self.cache[q]
            if offset == 10:
                items = self.find(q, 10)
                offset = 0
            self.cache[q] = (items, offset + 1)
            image = items[offset]
        else:
            items = self.find(q, 0)
            if len(items) == 0:
                telegram.send(chat, "Nothing found")
                return
            image = items[0]
            if self.cache_list == 10:
                last = self.cache_list[0]
                self.cache_list.pop(0)
                self.cache.pop(last, None)
            self.cache_list.append(q)
            self.cache[q] = (items, 1)

        image_url = image['link']
        image_response = urlfetch.fetch(image_url, method=urlfetch.GET)
        if image_response.status_code != 200:
            telegram.send(chat, "Error retrieving image")
            return
        image_name = urlparse.urlsplit(image_url).path.split('/')[-1]
        telegram.send_image(chat, image_response.content, image_name, image['mime'])
Пример #4
0
def main():
    poke_api = PokeApi()
    # Update the list of subscribers.
    telegram.update_subscriptions()
    # Map image captions
    image_dictionary = {
        'back_default': 'Back',
        'back_shiny': 'Back Shiny',
        'front_default': 'Front',
        'front_shiny': 'Front Shiny',
        'back_female': 'Female Back',
        'back_shiny_female': 'Female Back Shiny',
        'front_female': 'Female Front',
        'front_shiny_female': 'Female Front Shiny'
    }

    # Get a random Pokemon.
    pokemon = poke_api.get_random_pokemon()
    for image in pokemon['sprites']:
        # Load the name of the image.
        image_name = '<strong>' + pokemon[
            'name'] + ':</strong> ' + image_dictionary[image]
        # Send the image to the subscribed users.
        telegram.send_image(pokemon['sprites'][image], image_name, 'HTML',
                            True)
    # Generate the message body.
    message = '<strong>' + pokemon['name'] + '</strong>' +\
              "\n" + '-------------------------' +\
              "\n" + '<b>Order:</b> ' + str(pokemon['order']) +\
              "\n" + '<b>Height:</b> ' + str(pokemon['height']) +\
              "\n" + '<b>Weight:</b> ' + str(pokemon['weight']) +\
              "\n" + '<b>Abilities:</b> ' + ', '.join(poke_utils.get_abilities(pokemon)) +\
              "\n" + '<b>Moves:</b> ' + ', '.join(poke_utils.get_moves_with_link(pokemon))
    # Send the message to the subscribed users.
    telegram.send_message(message, 'HTML')
Пример #5
0
 def call(self, chat, author, q):
     if self.google_search_key is None:
         self.google_search_key = db.get_key('google_search')
     data = {
         'key': self.google_search_key,
         'cx': '009373417816394415455:i3e_omr58us',
         'q': q.encode('utf-8'),
         'searchType': 'image',
         'num': 1
     }
     response = urlfetch.fetch(url='https://www.googleapis.com/customsearch/v1?' + urllib.urlencode(data), method=urlfetch.GET)
     items = json.loads(response.content)['items']
     if len(items) == 0:
         telegram.send(chat, "Nothing found")
         return
     image = items[0]
     image_url = image['link']
     image_response = urlfetch.fetch(image_url, method=urlfetch.GET)
     if image_response.status_code != 200:
         telegram.send(chat, "Error retrieving image")
         return
     image_name = urlparse.urlsplit(image_url).path.split('/')[-1]
     telegram.send_image(chat, image_response.content, image_name, image['mime'])
Пример #6
0
	def send_image_brute_force(path_to_image, caption=None):
		all_dialogs = get_all_users()
		all_users_id = all_of_all_user_ids(all_dialogs)
		send_image(all_users_id, path_to_image, caption)
Пример #7
0
	def send_image_to_all_people(path_to_image, caption=None):
		all_dialogs = get_all_users()
		all_users = get_all_users(all_dialogs)
		all_users = remove_all_bots(all_users)
		all_users = [user.id for user in all_users]
		send_image(all_users, path_to_image, caption)
Пример #8
0
	def send_image_to_all_groups(path_to_image, caption=None):
		all_dialogs = get_all_dialogs()
		all_groups = get_all_groups(all_dialogs)
		all_groups = [group.id for group in all_groups]
		send_image(all_groups, path_to_image, caption)
Пример #9
0
            #telegram = tg.Telegram('unix:///tmp/tg.sock') # For Unix Domain Socket
            msg = name
            telegram.send_message('david_reinhart', 'ada tamu datang ' + msg)
        elif conf > 80:
            unk = 'unknown'
            #print(unk)
            font = cv2.FONT_HERSHEY_SIMPLEX
            color = (255, 255, 255)
            stroke = 2
            cv2.putText(frame, unk, (x, y), font, 1, color, stroke,
                        cv2.LINE_AA)
            #telegram = tg.Telegram('unix:///tmp/tg.sock') # For Unix Domain Socket
            msg = 'identitas tak diketahui'
            telegram.send_message('david_reinhart', 'ada tamu datang ' + msg)
            img_item = "unk.png"
            cv2.imwrite(img_item, roy_color)
            telegram.send_image('david_reinhart', '/home/odroid/TA/unk.png')

        color = (255, 0, 0)
        stroke = 2
        end_coord_x = x + w
        end_coord_y = y + h
        cv2.rectangle(frame, (x, y), (end_coord_x, end_coord_y), color, stroke)

    cv2.imshow('frame', frame)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()