forked from jordan-wright/dumpmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dumpmon.py
67 lines (57 loc) · 1.85 KB
/
dumpmon.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
# dumpmon.py
# Author: Jordan Wright
# Version: 0.0 (in dev)
# ---------------------------------------------------
# To Do:
#
# - Refine Regex
# - Create/Keep track of statistics
from lib.regexes import regexes
from lib.Pastebin import Pastebin, PastebinPaste
from lib.Slexy import Slexy, SlexyPaste
from lib.Pastie import Pastie, PastiePaste
from lib.helper import log
from time import sleep
from twitter import Twitter, OAuth
from settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET, log_file
import threading
import logging
def monitor():
'''
monitor() - Main function... creates and starts threads
'''
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-v", "--verbose", help="more verbose", action="store_true")
args = parser.parse_args()
level = logging.INFO
if args.verbose:
level = logging.DEBUG
logging.basicConfig(
format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level)
logging.info('Monitoring...')
bot = Twitter(
auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET,
CONSUMER_KEY, CONSUMER_SECRET)
)
# Create lock for both output log and tweet action
log_lock = threading.Lock()
tweet_lock = threading.Lock()
pastebin_thread = threading.Thread(
target=Pastebin().monitor, args=[bot, tweet_lock])
slexy_thread = threading.Thread(
target=Slexy().monitor, args=[bot, tweet_lock])
pastie_thead = threading.Thread(
target=Pastie().monitor, args=[bot, tweet_lock])
for thread in (pastebin_thread, slexy_thread, pastie_thead):
thread.daemon = True
thread.start()
# Let threads run
try:
while(1):
sleep(5)
except KeyboardInterrupt:
logging.warn('Stopped.')
if __name__ == "__main__":
monitor()