Giter VIP home page Giter VIP logo

group-activity-bot-rs's Introduction

Group Activity Bot

Group Activity Bot (GAB) is a Telgram bot that will keep track of user activities in groups, e.g.

Screenshot 2022-02-10 at 13 57 41

GAB only works in group and must be a group admin in order to receive each user message in a group

Features

Command Action
/groupstats Returns a message containing the total number of messages exchanged in the group and the percentege of messages per user, with nice emojis for the top 3 users
/userstats <username> Returns a message containing the percentage of messages of a specific user in a group
/statsfile Returns a .csv file containing (message timestamp, username) for all the messages exchanged in a group, this is helpful to plot graphs and other analytics with other softwares

How to run

I personally run rust bots on my raspberry and let systemd handle them

Configuration

Create a service file, e.g. /etc/systemd/system/bot.service

[Unit]
Description=Telegram Bot Service
After=network.target

[Service]
Type=simple
User=<user>
Group=<group>
Restart=always
RestartSec=10
ExecStart=/usr/local/bin/bot
Environment="TELOXIDE_TOKEN=<token>"

[Install]
WantedBy=multi-user.target

Copy the bot binary in /usr/local/bin/

Run

Enable the service so that it boots on reboot and start it

$ sudo systemctl enable bot.service
$ sudo systemctl start bot.service

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.