Browse Source

Update follow stuffs, you're on your own with this

master
KemoNine 3 years ago
parent
commit
1c2ca69278
  1. 33
      botstreamlisteners.py

33
botstreamlisteners.py

@ -56,10 +56,10 @@ CREATE TABLE IF NOT EXISTS notification_cache (
# Replay any toots that were missed while offline and welcome new users
print('Replaying missed toots')
self.replay_toots(True)
#self.replay_toots(True)
print(' Replay complete')
print('Replaying missed notifications')
self.replay_notifications()
#self.replay_notifications()
print(' Replay complete')
def __del__(self):
@ -344,15 +344,30 @@ CREATE TABLE IF NOT EXISTS follow_cache (
self.conn.commit()
def process_toot(self, status):
if 'reblog' in status:
status = status['reblog']
"""Method that follows unseen users."""
federated = '@' in status['account']['acct']
print('========================')
pprint.pprint(status)
if 'reblog' in status and status['reblog'] is not None:
print('has reblog!')
status = status['reblog']
else:
print('no reblog')
return # No need for additional stuff below if it's not a boost
if status is None:
print('status is none?')
return # Avoid a potential null error when not a reblog
username = status['account']['acct']
federated = '@' in username
instance = None
print(username)
if federated:
print(' IS federated')
instance = status['account']['acct'].split('@')[1]
timestamp = status['created_at']
visibility = status['visibility']
@ -361,6 +376,9 @@ CREATE TABLE IF NOT EXISTS follow_cache (
and instance.lower() not in (instance.lower() for instance in self.bot_config['follow']['blacklist']['instances']) \
and username.lower() not in (user.lower() for user in self.bot_config['follow']['blacklist']['users']) \
and 'nobot' not in status['account']['note'].lower():
print(' go ahead with follow')
# ABOVE CONDITIONAL WARNING: depending on how the formatted bio looks, #nobot may not match!!!!!
# Deal with tag processing
@ -373,6 +391,7 @@ CREATE TABLE IF NOT EXISTS follow_cache (
break
# Bail out of toot wasn't tagged properly
if not tags_ok:
print(' no tags matched')
return
# Check if username has been seen for welcome
@ -380,8 +399,11 @@ CREATE TABLE IF NOT EXISTS follow_cache (
'select count(1) as found from follow_cache where username = ?',
(username, ))
if self.cursor.fetchone()[0] > 0:
print(' already followed (cached), returning')
return
print(' following')
mastodon = Mastodon(
client_id=self.bot_config['config']['client_cred_file'],
access_token=self.bot_config['config']['user_cred_file'],
@ -394,4 +416,5 @@ CREATE TABLE IF NOT EXISTS follow_cache (
self.cursor.execute('insert into follow_cache values (?, ?)',
(username, timestamp))
self.conn.commit()
print(' processing complete')
Loading…
Cancel
Save