-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot.py
More file actions
136 lines (125 loc) · 4.94 KB
/
bot.py
File metadata and controls
136 lines (125 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from mastodon import Mastodon
import random
import requests
import time
import os
import json
import sys
describy = ["awesome", "cool", "swag", "amazing"]
kats = ["cat", "kat", "kitty"]
f = open('bot_config.json','r')
bot_config = json.load(f)
tootdur = bot_config['dur']
mastodon = Mastodon(
client_id = os.environ['client_id'],
client_secret = os.environ['client_secret'],
access_token = os.environ['access_token'],
api_base_url = os.environ['baseurl']
)
#mastodon.log_in(
# '1@2.com',
# 'goodpass123',
# to_file = '.secrets'
#)
def get_random_unicode(length):
try:
get_char = unichr
except NameError:
get_char = chr
# Update this to include code point ranges to be sampled
include_ranges = [
( 0x0021, 0x0021 ),
( 0x0023, 0x0026 ),
( 0x0028, 0x007E ),
( 0x00A1, 0x00AC ),
( 0x00AE, 0x00FF ),
( 0x0100, 0x017F ),
( 0x0180, 0x024F ),
( 0x2C60, 0x2C7F ),
( 0x16A0, 0x16F0 ),
( 0x0370, 0x0377 ),
( 0x037A, 0x037E ),
( 0x0384, 0x038A ),
( 0x038C, 0x038C ),
]
alphabet = [
get_char(code_point) for current_range in include_ranges
for code_point in range(current_range[0], current_range[1] + 1)
]
return ''.join(random.choice(alphabet) for i in range(length))
def tootuz(num):
print(str(num))
if num == 0:
tootus = "func1"
tootify(tootus)
mastodon.status_post(status="func1", visibility='unlisted')
if num == 1:
tootus = 'Check out my ' + random.choice(describy) + ' ' + random.choice(kats)
kitty = requests.get("https://thiscatdoesnotexist.com")
kittyjson = mastodon.media_post(kitty.content, 'image/png')
print(kittyjson)
tootify(tootus)
mastodon.status_post(status=tootus, media_ids=kittyjson['id'], visibility='unlisted')
if num == 2:
print('Grabbing fake human.')
r = requests.get('https://thispersondoesnotexist.com/image')
mastodon.account_update_credentials(avatar=r.content, avatar_mime_type = 'image/jpeg', fields=[('unix', str(time.time()))])
tootify2('New Human!', r.content, 'image/jpeg')
if num == 3:
r = requests.get("https://v2.jokeapi.dev/joke/Programming,Miscellaneous?format=txt")
tootify2(r.text, None, None)
if num == 4:
red = requests.get('https://abnuosite.herokuapp.com/imgur2.php')
r = requests.get(red.url)
imgurpic = mastodon.media_post(r.content, 'image/png')
mastodon.status_post(status='De Imgur Has Spoken', media_ids=imgurpic['id'], visibility='unlisted', sensitive=True)
if num == 5:
r = requests.get('https://yomomma-api.herokuapp.com/jokes')
penis = json.loads(r.text)
tootify2(penis['joke'], None, None)
if num == 6:
r = requests.get('https://api.kanye.rest/')
penis = json.loads(r.text)
tootify2('A wise man once said this... ' + penis['quote'], None, None)
if num == 7:
print('Tooting -> Noise video')
os.system('ffmpeg -y -f rawvideo -video_size 100x100 -pixel_format yuv420p -framerate 25 -i /dev/urandom -ar 48000 -ac 2 -f s16le -i /dev/urandom -t 5 output.mp4')
f = open('output.mp4', 'rb')
vids = mastodon.media_post(f.read(), 'video/mp4')
mastodon.status_post(status=get_random_unicode(10), media_ids=vids['id'], visibility='unlisted')
if num == 8:
print('Tooting -> Noise image')
os.system('ffmpeg -y -f rawvideo -s 100x100 -pixel_format yuv420p -i /dev/urandom output.png')
f = open('output.png', 'rb')
pics = mastodon.media_post(f.read(), 'image/png')
mastodon.status_post(status=get_random_unicode(10), media_ids=pics['id'], visibility='unlisted')
if num == 9:
print('Tooting -> Tube Vid')
r = requests.get('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=50&playlistId=PLjj6IXQ4Ot2QT18SIC6ecnYswnr6NF_aO&key=AIzaSyD15CYK9cckYa1Qy7BXqFNqiDR4YAFG6rI')
scatnis = r.json()
video = scatnis['items'][random.randint(0, len(scatnis['items']))]['contentDetails']['videoId']
os.system('yt-dlp -o - ' + video + ' | ffmpeg -i pipe: -t 10 butt.mp4')
f = open('butt.mp4', 'rb')
vids = mastodon.media_post(f.read(), 'video/mp4')
mastodon.status_post(status='Watch', media_ids=vids['id'], visibility='unlisted')
os.remove('butt.mp4')
def tootify(fart):
print('Tooting -> ' + str(fart))
def tootify2(fart, media, mime):
print('Tooting -> ' + str(fart))
if media == None:
try:
mastodon.status_post(status=fart, visibility='unlisted')
except Exception as e:
print('FartError: ' + str(e))
if media != None:
try:
mediaj = mastodon.media_post(media, mime)
mastodon.status_post(status=fart, media_ids=mediaj['id'], visibility='unlisted')
except Exception as e:
print('FartError: ' + str(e))
if len(sys.argv) > 1:
tootuz(int(sys.argv[1]))
else:
tootuz(random.randint(0, 9))
#tootuz(2)