-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_autofn.py
81 lines (70 loc) · 2.1 KB
/
my_autofn.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from multiprocessing import Process
import tweepy
import time
import logging
import json
import requests
from config import create_api
from follow import follow_followers
from justlk import TListener
from rply_BTC import check_mentions
#from rply_ETH import check_mention
from tagged import check_mentioning
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
#add in bitcoin current price retrieval
#Powered by CoinDesk
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
data = response.json()
#print(data["bpi"]["USD"]["rate"])
#If you want to see the price uncomment
#add in ethereum current price retrieval
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
data = response.json()
#print(data["bpi"]["USD"]["rate"])
#If you want to see the price uncomment
def streamer():
api = create_api()
tweets_listener = TListener(api)
stream = tweepy.Stream(api.auth, tweets_listener)
stream.filter(track=["crypto", "ethereum", "DeFi", "science","covid","coffee", "bankless"], languages=["en"])
def follow():
api = create_api()
while True:
follow_followers(api)
logger.info("Sleeping...")
time.sleep(180)
def BTC():
api = create_api()
since_id = 1
while True:
since_id = check_mentions(api, ["BTC", "Bitcoin"], since_id)
logger.info("Searching...")
time.sleep(1000)
def tagged():
api = create_api()
since_ids = 1
while True:
since_ids = check_mentioning(api, since_ids)
logger.info("Searching...")
time.sleep(300)
#def ETH():
#api = create_api()
#since_ids = 1
#while True:
#since_ids = check_mention(api, ["ETH", "Ethereum", "Ether", "the best crypto"], since_ids)
#logger.info("Searching...")
#time.sleep(1000)
if __name__ == "__main__":
p1 = Process(target=streamer)
p1.start()
p2 = Process(target=follow)
p2.start()
p3 = Process(target=tagged)
p3.start()
#p4 = Process(target=reply)
#p4.start()
p5 = Process(target=BTC)
p5.start()
#p6 = Process(target=ETH)
#p6.start()