-
Notifications
You must be signed in to change notification settings - Fork 3
/
init_twitter_hashtag.py
58 lines (43 loc) · 1.93 KB
/
init_twitter_hashtag.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
"""
Philosopher Bot
---------------
Created by Caio Madeira
Co-worker: Rodrigo Carmo
instagram: @sudomadeira
Twitter: @bot_philospher
Avaliable on Discord too!
"""
import tweepy
from config import Config
from Logs.Twitter.log_engine import LogEngine
from urllib3.exceptions import ProtocolError
class StartHashtagExtension:
def __init__(self):
get_config = Config()
""" =========== HASHTAGS =========== """
self.PHILOBOT_HASHTAG = get_config.PHILOBOT__HASHTAG
self.PHILOMAKER_HASHTAG = get_config.PHILOMAKER__HASHTAG
""" =========== SUBLIST =========== """
self.PHILOBOT__SUBLIST = get_config.PHILOBOT__SUBLIST
self.PHILOMAKER_SUBLIST = get_config.PHILOMAKER__SUBLIST
self.TESTEPHILO__SUBLIST = get_config.TESTEPHILO__SUBLIST
self.TESTMAKER_SUBLIST = get_config.TESTMAKER__SUBLIST
"""=========== SET LOG ==========="""
self.log = LogEngine(__name__).log_hashtag()
self.start_hashtag_extension()
def start_hashtag_extension(self):
self.log.info("Bem-vindo!\n")
self.log.info("Philosopher BOT por Caio Madeira e Rodrigo Carmo\n")
self.log.info(">INICIANDO HASHTAG - EXTENSION<")
from Twitter.Hashtag.hashtag import HashtagClass
from Credentials.Twitter.Extension.hashtag_credentials_extension import API_HASHTAG_EXTENSION as api_reserva
try:
Philobot_Stream = tweepy.Stream(auth=api_reserva.auth,
listener=HashtagClass(self.PHILOBOT__SUBLIST, api_reserva, LOG=self.log),
include_rts=False)
Philobot_Stream.filter(track=[self.PHILOBOT_HASHTAG], is_async=True)
except (Exception, ProtocolError, AttributeError) as stream:
self.log.error('[X] - ERRO AO INICIAR O STREAM COM A API DO TWITTER')
self.log.error(stream)
if __name__ == '__main__':
StartHashtagExtension()