stats: Move markdown handling into stats methods and add escape_markdown

pull/1/head
Michael DM Dryden 2020-05-30 00:31:32 -04:00
rodzic a0d98d6eb6
commit ec83a7a691
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -139,7 +139,9 @@ class StatsRunner(object):
df.columns = ['User', 'Total Messages', 'Percent']
df['User'] = df['User'].str.replace(r'[^\x00-\x7F]', "", regex=True)
return df.iloc[:n].to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}"), None
text = df.iloc[:n].to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}")
return f"```\n{text}\n```", None
def get_counts_by_hour(self, user: Tuple[int, str] = None, start: str = None, end: str = None)\
-> Tuple[None, BytesIO]:

5
utils.py 100644
Wyświetl plik

@ -0,0 +1,5 @@
import re
def escape_markdown(string: str) -> str:
return re.sub(r'([\\_*\[\]()`])', r'\\\g<1>', string)