forked from Charcoal-SE/SmokeDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globalvars.py
253 lines (238 loc) · 13 KB
/
globalvars.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# -*- coding: utf-8 -*-
import os
from datetime import datetime
from ChatExchange.chatexchange.client import Client
import HTMLParser
import md5
import ConfigParser
class GlobalVars:
false_positives = []
whitelisted_users = []
blacklisted_users = []
ignored_posts = []
auto_ignored_posts = []
startup_utc = datetime.utcnow().strftime("%H:%M:%S")
latest_questions = []
blockedTime = 0
api_backoff_time = 0
charcoal_room_id = "11540"
meta_tavern_room_id = "89"
socvr_room_id = "41570"
site_filename = {"electronics.stackexchange.com": "ElectronicsGood.txt",
"gaming.stackexchange.com": "GamingGood.txt", "german.stackexchange.com": "GermanGood.txt",
"italian.stackexchange.com": "ItalianGood.txt", "math.stackexchange.com": "MathematicsGood.txt",
"spanish.stackexchange.com": "SpanishGood.txt", "stats.stackexchange.com": "StatsGood.txt"}
experimental_reasons = [] # Don't widely report these
non_tavern_reasons = ["All-caps title", # Don't report in the Tavern
"All-caps body",
"All-caps answer",
"All-caps body, all-caps title",
"Repeating characters in body",
"Repeating characters in title",
"Repeating characters in answer",
"Few unique characters in body",
"Few unique characters in answer",
"Title has only one unique char",
"Phone number detected in title",
"Offensive body detected",
"Email in answer",
"Email in title",
"Link at end of answer"]
non_tavern_sites = ["stackoverflow.com"]
parser = HTMLParser.HTMLParser()
wrap = Client("stackexchange.com")
wrapm = Client("meta.stackexchange.com")
wrapso = Client("stackoverflow.com")
privileged_users = {charcoal_room_id: ["117490", # Normal Human
"66258", # Andy
"31768", # ManishEarth
"103081", # hichris123
"73046", # Undo
"88521", # ProgramFOX
"59776", # Doorknob
"31465", # Seth
"88577", # Santa Claus
"34124", # Andrew Leach
"54229", # apnorton
"20459", # S.L. Barth
"32436", # tchrist
"30477", # Brock Adams
"58529", # ferrybig
"145208", # Robert Longson
"178825", # Ms Yvette
"171800", # JAL
"64978", # PeterJ
"125141", # Jeffrey Bosboom
"54902", # bummi
"135450", # M.A.R.
"145604", # Quill
"60548", # rene
"121401", # michaelpri
"116218", # JamesENL
"82927", # Braiam
"11606", # bwDraco
"19761", # Ilmari Karonen
"108271", # Andrew T.
"137665"], # ByteCommander
meta_tavern_room_id: ["259867", # Normal Human
"244519", # CRABOLO
"244382", # TGMCians
"194047", # Jan Dvorak
"158100", # rene
"178438", # Manishearth
"237685", # hichris123
"215468", # Undo
"229438", # ProgramFOX
"180276", # Doorknob
"161974", # Lynn Crumbling
"186281", # Andy
"266094", # Unihedro
"245167", # Infinite Recursion
"230261", # Jason C
"213575", # Braiam
"241919", # Andrew T.
"203389", # backwards-Seth
"202832", # Mooseman
"160017", # bwDraco
"201151", # bummi
"188558", # Frank
"229166", # Santa Claus
"159034", # Kevin Brown
"203972", # PeterJ
"188673", # Alexis King
"258672", # AstroCB
"227577", # Sam
"255735", # cybermonkey
"279182", # Ixrec
"271104", # James
"220428", # Qantas 94 Heavy
"153355", # tchrist
"238426", # Ed Cottrell
"166899", # Second Rikudo
"287999", # ASCIIThenANSI
"208518", # JNat
"284141", # michaelpri
"260312", # vaultah
"244062", # SouravGhosh
"152859", # Shadow Wizard
"201314", # apnorton
"280934", # M.A.Ramezani
"200235", # durron597
"148310", # Awesome Poodles / Brock Adams
"168333", # S.L. Barth
"257207", # Unikitty
"244282", # DroidDev
"163250", # Cupcake
"298265", # BoomsPlus
"253560", # josilber
"244254", # misterManSam
"188189", # Robert Longson
"174699", # Ilmari Karonen
"202362", # chmod 666 telkitty
"289717", # Quill
"237813", # bjb568
"311345", # Simon Klaver
"171881", # rekire
"260388", # Pandya
"310756", # Ms Yvette
"262399", # Jeffrey Bosboom
"242209", # JAL
"280883", # ByteCommander
"302251"], # kos
socvr_room_id: [
"1849664", # Undo
"2581872", # hichris123
"1198729", # Manishearth
"3717023", # Normal Human aka 1999
"2619912", # ProgramFOX
"578411", # rene
"1043380", # gunr2171
"2246344", # Sam
"2756409", # TylerH
"1768232", # durron597
"359284", # Kevin Brown
"258400", # easwee
"3622940", # Unihedron
"3204551", # Deduplicator
"4342498", # NathanOliver
"4639281", # Tiny Giant
"3093387", # josilber
"1652962", # cimmanon
"1677912", # Mogsdad
"656243", # Lynn Crumbling
"3933332", # Rizier123
"2422013", # cybermonkey
"3478852", # Nisse Engström
"2302862", # Siguza
"1324", # Paul Roub
"1743880", # Tunaki
"1663001", # DavidG
"2415822", # JAL
"4174897", # Kyll
"5299236", # Kevin Guan
"4050842", # Thaillie
"1816093", # Drew
"874188", # Triplee
"880772", # approxiblue
"1835379", # Cerbrus
"1843331", # Tim Castelijns
"3956566", # JamesENL
"2357233", # Ms Yvette
"3155639", # AlexanderOMara
"462627", # Praveen Kumar
"4490559", # intboolstring
"1364007", # Wai Ha Lee
"1699210", # bummi
"563532", # Rob
"5389107", # Magisch
"4099593", # bhargav-rao
"1542723", # Ferrybig
"2025923", # Tushar
"5292302", # Petter Friberg
"792066", # Braiam
"5666987"] # Ian
}
smokeDetector_user_id = {charcoal_room_id: "120914", meta_tavern_room_id: "266345",
socvr_room_id: "3735529"}
censored_committer_names = {"3f4ed0f38df010ce300dba362fa63a62": "Undo1"}
commit = os.popen('git log --pretty=format:"%h" -n 1').read()
commit_author = os.popen('git log --pretty=format:"%cn" -n 1').read()
if md5.new(commit_author).hexdigest() in censored_committer_names:
commit_author = censored_committer_names[md5.new(commit_author).hexdigest()]
commit_with_author = os.popen('git log --pretty=format:"%h (' + commit_author + ': *%s*)" -n 1').read()
on_master = os.popen("git rev-parse --abbrev-ref HEAD").read().strip() == "master"
charcoal_hq = None
tavern_on_the_meta = None
socvr = None
s = ""
s_reverted = ""
specialrooms = []
apiquota = -1
bodyfetcher = None
se_sites = []
users_chatting = {meta_tavern_room_id: [], socvr_room_id: [], charcoal_room_id: []}
why_data = []
why_data_allspam = []
notifications = []
listen_to_these_if_edited = []
multiple_reporters = []
api_calls_per_site = {}
config = ConfigParser.RawConfigParser()
config.read('config')
latest_smokedetector_messages = {meta_tavern_room_id: [], charcoal_room_id: [],
socvr_room_id: []}
site_id_dict = {}
post_site_id_to_question = {}
location = config.get("Config", "location")
print location
try:
metasmoke_host = config.get("Config", "metasmoke_host")
print metasmoke_host
except ConfigParser.NoOptionError:
metasmoke_host = None
print "metasmoke host not found. Set it as metasmoke_host in the config file. See https://github.com/Charcoal-SE/metasmoke."
try:
metasmoke_key = config.get("Config", "metasmoke_key")
except ConfigParser.NoOptionError:
metasmoke_key = ""
print "No metasmoke key found, which is okay if both are running on the same host"