kopia lustrzana https://github.com/mkdryden/telegram-stats-bot
Shortened Usernames, readability on mobiles
Ive shortened the /stats Output to make it readable on mobiles better: Shortened /stats counts columns to User, Messages, % added a maximum length of 15 to the df['User'], if more it gets shortened and appended by "..."pull/23/head
rodzic
1f658bb391
commit
6899c5899e
|
@ -201,6 +201,8 @@ class StatsRunner(object):
|
|||
else:
|
||||
df.columns = ['User', 'Messages', '%']
|
||||
df['User'] = df['User'].str.replace(r'[^\x00-\x7F]|[@]', "", regex=True) # Drop emoji and @
|
||||
df['User'] = df['User'].astype(str) # convert to string if necessary
|
||||
df['User'] = df['User'].apply(lambda x: x[:15] + "..." if len(x) > 15 else x) # truncate and append "..."
|
||||
|
||||
text = df.iloc[:n].to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}")
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue