Yank unreliable Twitter module and related stuff
This commit is contained in:
parent
0e4a55f77a
commit
0839b653f4
1
Pipfile
1
Pipfile
|
@ -13,7 +13,6 @@ google-auth-httplib2 = "*"
|
||||||
google-auth-oauthlib = "*"
|
google-auth-oauthlib = "*"
|
||||||
requests = "*"
|
requests = "*"
|
||||||
igramscraper = "*"
|
igramscraper = "*"
|
||||||
twitterscraper = "*"
|
|
||||||
httpx = "*"
|
httpx = "*"
|
||||||
PyYAML = "==5.3"
|
PyYAML = "==5.3"
|
||||||
wolframalpha = "*"
|
wolframalpha = "*"
|
||||||
|
|
|
@ -189,7 +189,7 @@ New posts are sent to room. Polls only randomly every 30 to 60 minutes to keep
|
||||||
|
|
||||||
Commands:
|
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)
|
* 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)
|
* 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
|
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)
|
#### Matrix Messaging API (mxma)
|
||||||
|
|
||||||
This is a simple API to ask bot to send messages in Matrix using JSON file from external service.
|
This is a simple API to ask bot to send messages in Matrix using JSON file from external service.
|
||||||
|
|
|
@ -98,8 +98,6 @@ class BotModule(ABC):
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.enabled = True
|
self.enabled = True
|
||||||
if hasattr(self, "__init_enabled"):
|
|
||||||
self.__init_enabled(self.name)
|
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
|
|
|
@ -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)
|
|
Loading…
Reference in New Issue