mirror of https://github.com/zulip/zulip.git
Annotate bots/summarize_stream.py.
This commit is contained in:
parent
98ac51d07d
commit
54820de522
|
@ -7,8 +7,9 @@ import zulip
|
||||||
import re
|
import re
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
def get_recent_messages(client, narrow, count=100):
|
def get_recent_messages(client, narrow_str, count=100):
|
||||||
narrow = [word.split(':') for word in narrow.split()]
|
# type: (zulip.Client, str, int) -> List[Dict[str, Any]]
|
||||||
|
narrow = [word.split(':') for word in narrow_str.split()]
|
||||||
req = {
|
req = {
|
||||||
'narrow': narrow,
|
'narrow': narrow,
|
||||||
'num_before': count,
|
'num_before': count,
|
||||||
|
@ -22,6 +23,7 @@ def get_recent_messages(client, narrow, count=100):
|
||||||
return old_messages['messages']
|
return old_messages['messages']
|
||||||
|
|
||||||
def get_words(content):
|
def get_words(content):
|
||||||
|
# type: (str) -> List[str]
|
||||||
regex = "[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+"
|
regex = "[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+"
|
||||||
words = re.findall(regex, content, re.M)
|
words = re.findall(regex, content, re.M)
|
||||||
words = [w.lower() for w in words]
|
words = [w.lower() for w in words]
|
||||||
|
@ -29,6 +31,7 @@ def get_words(content):
|
||||||
return words
|
return words
|
||||||
|
|
||||||
def analyze_messages(msgs, word_count, email_count):
|
def analyze_messages(msgs, word_count, email_count):
|
||||||
|
# type: (List[Dict[str, Any]], Dict[str, int], Dict[str, int]) -> None
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
if False:
|
if False:
|
||||||
if ' ack' in msg['content']:
|
if ' ack' in msg['content']:
|
||||||
|
@ -47,6 +50,7 @@ def analyze_messages(msgs, word_count, email_count):
|
||||||
print('%-20s: %s' % (k, v))
|
print('%-20s: %s' % (k, v))
|
||||||
|
|
||||||
def generate_support_stats():
|
def generate_support_stats():
|
||||||
|
# type: () -> None
|
||||||
client = zulip.Client()
|
client = zulip.Client()
|
||||||
narrow = 'stream:support'
|
narrow = 'stream:support'
|
||||||
count = 2000
|
count = 2000
|
||||||
|
|
Loading…
Reference in New Issue