Yank unreliable Twitter module and related stuff

This commit is contained in:
Andreas Kotes 2020-11-15 21:24:17 +01:00
parent 0e4a55f77a
commit 0839b653f4
No known key found for this signature in database
GPG Key ID: 5C5E3BFE32B47A48
4 changed files with 1 additions and 43 deletions

View File

@ -13,7 +13,6 @@ google-auth-httplib2 = "*"
google-auth-oauthlib = "*"
requests = "*"
igramscraper = "*"
twitterscraper = "*"
httpx = "*"
PyYAML = "==5.3"
wolframalpha = "*"

View File

@ -189,7 +189,7 @@ New posts are sent to room. Polls only randomly every 30 to 60 minutes to keep
Commands:
Prefix with selected service, for example "!ig add accountname" or "!twitter list"
Prefix with selected service, for example "!ig add accountname" or "!teamup list"
* add [accountname] - Add account to this room (Must be done as room admin)
* del [accountname] - Delete account from room (Must be done as room admin)
@ -207,13 +207,6 @@ See: https://github.com/realsirjoe/instagram-scraper/
NOTE: disabled by default
#### Twitter
Polls twitter account(s). Uses twitter scraper library
without any authentication or api key.
See: https://github.com/taspinar/twitterscraper/tree/master/twitterscraper
#### Matrix Messaging API (mxma)
This is a simple API to ask bot to send messages in Matrix using JSON file from external service.

View File

@ -98,8 +98,6 @@ class BotModule(ABC):
def enable(self):
self.enabled = True
if hasattr(self, "__init_enabled"):
self.__init_enabled(self.name)
def disable(self):
self.enabled = False

View File

@ -1,32 +0,0 @@
import sys
import traceback
from modules.common.pollingservice import PollingService
# https://github.com/taspinar/twitterscraper/tree/master/twitterscraper
class MatrixModule(PollingService):
def __init__(self, name):
super().__init__(name)
self.service_name = 'Twitter'
self.enabled = False
def __init_enabled(self, name):
# importing this has massive sideeffects, so let's only do that when enabled
from twitterscraper import query_tweets_from_user
async def poll_implementation(self, bot, account, roomid, send_messages):
try:
tweets = query_tweets_from_user(account, limit=1)
self.logger.info(f'Polling twitter account {account} - got {len(tweets)} tweets')
for tweet in tweets:
if tweet.tweet_id not in self.known_ids:
if send_messages:
await bot.send_html(bot.get_room_by_id(roomid),
f'<a href="https://twitter.com{tweet.tweet_url}">Twitter {account}</a>: {tweet.text}',
f'Twitter {account}: {tweet.text} - https://twitter.com{tweet.tweet_url}')
self.known_ids.add(tweet.tweet_id)
except Exception:
self.logger.error('Polling twitter account failed:')
traceback.print_exc(file=sys.stderr)