diff --git a/stats.py b/stats.py index f945132..5cf5bb9 100644 --- a/stats.py +++ b/stats.py @@ -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]: diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..8af400e --- /dev/null +++ b/utils.py @@ -0,0 +1,5 @@ +import re + + +def escape_markdown(string: str) -> str: + return re.sub(r'([\\_*\[\]()`])', r'\\\g<1>', string)