GithubHelp home page GithubHelp logo

mattrighetti / group-activity-bot-rs Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 55 KB

Telegram Bot that measures user activity in a chat based on user messages

Rust 100.00%
telegram-bot rust telergam teloxide

group-activity-bot-rs's Introduction

                             _   _        _       _          _   _   _ 
             _ __ ___   __ _| |_| |_ _ __(_) __ _| |__   ___| |_| |_(_)
   ^ ^      | '_ ` _ \ / _` | __| __| '__| |/ _` | '_ \ / _ \ __| __| |     ___
  (o,o)     | | | | | | (_| | |_| |_| |  | | (_| | | | |  __/ |_| |_| |    (o o)
  (   )     |_| |_| |_|\__,_|\__|\__|_|  |_|\__, |_| |_|\___|\__|\__|_|   (  V  )
 --"-"--------------------------------------|___/---------------------------m-m---

group-activity-bot-rs's People

Contributors

mattrighetti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

group-activity-bot-rs's Issues

Sort group stats by key or by value

Hi @mattrighetti,
First of all, I'd like to say that I really like GroupActivityBot. However, when sending the command /groupstats@gactivitybot, the group stats result is returned in a random order.
I was wondering if you can fix this issue.

A possible solution could be to use BTrees which are known for having sorted keys.
Another possible solution is to sort the keys whenever they are used:
Instead of:

impl PrettyPrint for HashMap<String, f32> {
    fn pretty_print(&self) -> String {
        let mut builder = String::new();
        for (k, v) in self {
            builder.push_str(format!("{}: {:.2}%\n", k, v).as_str());
        }
        
        builder
    }
}

we could use this implementation with Itertools which extends the standard iterator so that it can be sorted:

use itertools::Itertools;  // itertools = "0.8"

impl PrettyPrint for HashMap<String, f32> {
    fn pretty_print(&self) -> String {
        let mut builder = String::new();
        for key in self.keys().sorted() {
          builder.push_str(format!("{}: {:.2}%\n", k, self[key]).as_str());
        }

        builder
    }
}

P.S I think it could be a nice idea if you change the main branch from master to main.

"I really appreciate the name change [because] it raises awareness.There are things that we accept as implicit, and we then realize that we can change them because they don't match our society."
Javier Cánovas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.