From 69dd8f57c27861d4884cdc4843488634d7c2b02e Mon Sep 17 00:00:00 2001 From: Matthew Blum <45472455+mblum6180@users.noreply.github.com> Date: Thu, 20 Apr 2023 12:12:22 -0400 Subject: [PATCH 1/3] Update everylot.py Added wide photo --- everylot/everylot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/everylot/everylot.py b/everylot/everylot.py index 17faac1..088d334 100644 --- a/everylot/everylot.py +++ b/everylot/everylot.py @@ -1,4 +1,4 @@ -#!/usr/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of everylotbot # Copyright 2016 Neil Freeman @@ -69,7 +69,7 @@ def __init__(self, database, def aim_camera(self): '''Set field-of-view and pitch''' - fov, pitch = 65, 10 + fov, pitch = 69, 10 try: floors = float(self.lot.get('floors', 0)) or 2 except TypeError: @@ -92,7 +92,9 @@ def aim_camera(self): if floors >= 10: fov, pitch = 90, 30 - + + if floors >= 99: + fov, pitch = 130, -15 return fov, pitch def get_streetview_image(self, key): From 454d6c26cfb4d46cd723ce1f070a50f43ff19ee6 Mon Sep 17 00:00:00 2001 From: Matthew Blum <45472455+mblum6180@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:27:27 -0400 Subject: [PATCH 2/3] Update to API v2 --- .gitignore | 1 + everylot/__init__.py | 2 +- everylot/bot.py | 25 ++++++++++++++++++++++--- setup.py | 4 +++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fcdec5f..9cfd062 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ dist *.shx *.dbf *.shp.xml +bots.yaml \ No newline at end of file diff --git a/everylot/__init__.py b/everylot/__init__.py index 0fad76d..961fa94 100644 --- a/everylot/__init__.py +++ b/everylot/__init__.py @@ -15,5 +15,5 @@ from . import everylot -__version__ = '0.3.1' +__version__ = '0.3.2' __all__ = ['everylot'] diff --git a/everylot/bot.py b/everylot/bot.py index 0c7d792..adacc8e 100644 --- a/everylot/bot.py +++ b/everylot/bot.py @@ -19,6 +19,8 @@ import twitter_bot_utils as tbu from . import __version__ as version from .everylot import EveryLot +import tweepy +from twitter_bot_utils.confighelper import configure def main(): @@ -34,6 +36,16 @@ def main(): args = parser.parse_args() api = tbu.api.API(args) + + config = configure(args.screen_name) + consumer_key = config["consumer_key"] + consumer_secret = config["consumer_secret"] + access_token = config.get("token", config.get("key", config.get("oauth_token"))) + access_token_secret = config.get("secret", config.get("oauth_secret")) + client = tweepy.Client( + consumer_key=consumer_key, consumer_secret=consumer_secret, + access_token=access_token, access_token_secret=access_token_secret +) logger = logging.getLogger(args.screen_name) logger.debug('everylot starting with %s, %s', args.screen_name, args.database) @@ -55,7 +67,7 @@ def main(): # ("sv.jpg" is a dummy value, since filename is a required parameter). image = el.get_streetview_image(api.config['streetview']) media = api.media_upload('sv.jpg', file=image) - + # compose an update with all the good parameters # including the media string. update = el.compose(media.media_id_string) @@ -63,9 +75,16 @@ def main(): if not args.dry_run: logger.debug("posting") - status = api.update_status(**update) + response = client.create_tweet( + text=update['status'], + media_ids=[media.media_id_string] + ) + + # Extract the id from the response + tweet_id = response.data['id'] + try: - el.mark_as_tweeted(status.id) + el.mark_as_tweeted(tweet_id) except AttributeError: el.mark_as_tweeted('1') diff --git a/setup.py b/setup.py index 73eaaed..6b391da 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,10 @@ license='GPL-3.0', include_package_data=False, install_requires=[ - 'twitter_bot_utils>=0.11.5,<=0.12', + 'twitter_bot_utils>=0.11.5,<=0.14', # Updated to 0.14 + 'tweepy>=4.0.0' ], + entry_points={ 'console_scripts': [ 'everylot=everylot.bot:main', From 0ad57e6a5554d19a8059d3f0cb57db91db455857 Mon Sep 17 00:00:00 2001 From: Matthew Blum <45472455+mblum6180@users.noreply.github.com> Date: Sat, 24 Jun 2023 14:06:24 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index bd3889a..f8da731 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +# Updated to use Twitter API v2 endpoint for sending the tweet. +Now uses tweepy 4.0 and up. +twitter bot utils 0.14 + + # every lot bot This library supports a Twitter bot that posts Google Streetview pictures of every property in an SQLite database.