1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- from mastodon import Mastodon
- import re
- import os
- import time
- # Register your app! This only needs to be done once (per server, or when
- # distributing rather than hosting an application, most likely per device and server).
- # Uncomment the code and substitute in your information:
- '''
- Mastodon.create_app(
- 'grapeapp',
- api_base_url = 'https://noc.social/',
- to_file = 'grapeapp_clientcred.secret'
- )
- '''
- mastodon = Mastodon(client_id = 'grapeapp_clientcred.secret',)
- mastodon.log_in(
- 'nocsocial@teets.us',
- 'WW936dQL1H0w9zLsWvyh3Z3e1yFrE39oYoxmdARCIk8IcrBH',
- to_file = 'grapeapp_usercred.secret'
- )
- mastodon = Mastodon(access_token = 'grapeapp_usercred.secret')
- mostRecentMentionRepliedTo = ''
- while True:
- mostRecentMention = mastodon.notifications(types = "mention")[0].status.content
- if mostRecentMention == mostRecentMentionRepliedTo:
- time.sleep(15)
- continue
- mostRecentMentionRepliedTo = mostRecentMention
- cleanTags = re.compile('<.*?>')
- tweetWithoutTags = re.sub(cleanTags, '', mostRecentMention)
- cleanMention = re.compile('@developer(@noc\.social)*')
- tweetWithoutMention = re.sub(cleanMention, '', tweetWithoutTags)
-
- cleanTweet = re.sub(r'[^a-zA-Z0-9 ]', '', tweetWithoutMention)
- rawInput = cleanTweet.strip()[:45]
- print(rawInput)
- os.system('python stable.py "' + rawInput + '"')
- cleanSpaces = re.compile(' ')
- folderName = re.sub(cleanSpaces, '_', rawInput)
- print(folderName)
- mentionerUrl = mastodon.notifications(types = "mention")[0].status.account.url
- cleanProtocol = re.compile('https*:\/\/')
- cleanedUrl = re.sub(cleanProtocol, '', mentionerUrl)
- urlParts = cleanedUrl.split("/")
- mentionTag = urlParts[1] + '@' + urlParts[0]
- print(mentionTag)
- mediaId = mastodon.media_post(media_file = 'C:\\Users\\bigd\\Downloads\\stable-diffusion-main\\stable-diffusion-main\\outputs\\txt2img-samples\\' + folderName + '\\seed_28_00000.png', mime_type = 'image/png')
- message = mentionTag + ' mentioned me and said: "' + tweetWithoutMention.strip() + '". Here\'s my dream about that!'
- mastodon.status_post(status = message, media_ids = mediaId)
|