Skip to content
Permalink
Browse files

Merge pull request #1135 from quartata/master

Backporting NG chat system
  • Loading branch information...
quartata committed Dec 6, 2017
2 parents 5ed63bb + 51d9373 commit 29b89721e5bb84ae06a8135b187267f5cd514bb7
Showing with 2,604 additions and 2,713 deletions.
  1. +2 −0 .codeclimate.yml
  2. +2 −0 .gitignore
  3. +12 −9 bodyfetcher.py
  4. +789 −1,236 chatcommands.py
  5. +402 −266 chatcommunicate.py
  6. +8 −50 datahandling.py
  7. +10 −3 deletionwatcher.py
  8. +4 −314 globalvars.py
  9. +0 −3 helpers.py
  10. +20 −13 metasmoke.py
  11. +22 −44 parsing.py
  12. +1 −0 requirements.txt
  13. +404 −0 rooms.yml
  14. +15 −93 spamhandling.py
  15. +0 −1 test/data_test_parsing.txt
  16. +10 −0 test/fake.py
  17. +479 −0 test/test_chatcommands.py
  18. +331 −486 test/test_chatcommunicate.py
  19. +13 −13 test/test_globalvars.py
  20. +22 −23 test/test_parsing.py
  21. +48 −0 test/test_rooms.yml
  22. +1 −1 tox.ini
  23. +9 −158 ws.py
@@ -0,0 +1,2 @@
exclude_paths:
- test/*
@@ -68,6 +68,7 @@ apiCalls.pickle
bodyfetcherQueue.p
bodyfetcherQueueTimings.p
bodyfetcherMaxIds.p
messageData.p

# Settings files
.settings/
@@ -86,6 +87,7 @@ test/.cache/

# Config
config
rooms_custom.yml

# Ignore .DS_Store file (usually seen in Mac environments)
.DS_Store
@@ -2,6 +2,7 @@
from spamhandling import handle_spam, check_if_spam
from datahandling import (add_or_update_api_data, clear_api_data, store_bodyfetcher_queue, store_bodyfetcher_max_ids,
store_queue_timings)
from chatcommunicate import tell_rooms_with
from globalvars import GlobalVars
from operator import itemgetter
from datetime import datetime
@@ -280,23 +281,25 @@ def make_api_call_for_site(self, site):
message_hq = ""
if "quota_remaining" in response:
if response["quota_remaining"] - GlobalVars.apiquota >= 5000 and GlobalVars.apiquota >= 0:
GlobalVars.charcoal_hq.send_message("API quota rolled over with {0} requests remaining. "
"Current quota: {1}.".format(GlobalVars.apiquota,
response["quota_remaining"]))
tell_rooms_with("debug", "API quota rolled over with {0} requests remaining. "
"Current quota: {1}.".format(GlobalVars.apiquota,
response["quota_remaining"]))

sorted_calls_per_site = sorted(GlobalVars.api_calls_per_site.items(), key=itemgetter(1), reverse=True)
api_quota_used_per_site = ""
for site_name, quota_used in sorted_calls_per_site:
sanatized_site_name = site_name.replace('.com', '').replace('.stackexchange', '')
api_quota_used_per_site += sanatized_site_name + ": {0}\n".format(str(quota_used))
api_quota_used_per_site = api_quota_used_per_site.strip()
GlobalVars.charcoal_hq.send_message(api_quota_used_per_site, False)

tell_rooms_with("debug", api_quota_used_per_site)
clear_api_data()
if response["quota_remaining"] == 0:
GlobalVars.charcoal_hq.send_message("API reports no quota left! May be a glitch.")
GlobalVars.charcoal_hq.send_message(str(response)) # No code format for now?
tell_rooms_with("debug", "API reports no quota left! May be a glitch.")
tell_rooms_with("debug", str(response)) # No code format for now?
if GlobalVars.apiquota == -1:
GlobalVars.charcoal_hq.send_message("Restart: API quota is {quota}."
.format(quota=response["quota_remaining"]))
tell_rooms_with("debug", "Restart: API quota is {quota}."
.format(quota=response["quota_remaining"]))
GlobalVars.apiquota = response["quota_remaining"]
else:
message_hq = "The quota_remaining property was not in the API response."
@@ -316,7 +319,7 @@ def make_api_call_for_site(self, site):
GlobalVars.api_request_lock.release()

if len(message_hq) > 0:
GlobalVars.charcoal_hq.send_message(message_hq.strip())
tell_rooms_with("debug", message_hq.strip())

if "items" not in response:
return

0 comments on commit 29b8972

Please sign in to comment.
You can’t perform that action at this time.