-
Notifications
You must be signed in to change notification settings - Fork 0
/
BruhBot.py
58 lines (42 loc) · 1.18 KB
/
BruhBot.py
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
from random import uniform, seed
import math
import time
import tweepy
from BruhGenerator import BruhGenerator
from PerlinNoise import PerlinNoise
CONFIG= {}
CONFIG['T_CONSUMER_KEY'] = ''
CONFIG['T_CONSUMER_KEY'] = ''
CONFIG['T_ACCESS_TOKEN'] = ''
CONFIG['T_ACCESS_TOKEN_SECR'] = ''
CONFIG['debug'] = True
def getTwittingFunction():
'''
Function that returns the tweeting function
'''
if CONFIG['debug']:
return print
twi_auth = tweepy.OAuthHandler(CONFIG['T_CONSUMER_KEY'], CONFIG['T_CONSUMER_KEY_SECR'])
twi_auth.set_access_token(CONFIG['T_ACCESS_TOKEN'], CONFIG['T_ACCESS_TOKEN_SECR'])
t_api = tweepy.API(twi_auth)
return t_api.update_status
seed(time.time())
perlin = PerlinNoise()
# Initiate a generator with the perlin noise function as
# the random variable for the state transitions
generator = BruhGenerator(perlin.calculate1D)
tweet = getTwittingFunction()
starting_val = uniform(0,0.5)
# Main loop
while True:
new_bruh = generator.getBruh(starting_val)
try:
tweet(new_bruh)
except tweepy.TweepError as error:
if error.api_code == 187:
print('Error, repeated tweet')
else:
raise(error)
print('He tuiteado ', new_bruh)
starting_val += 1
time.sleep(1 * 30)