Coder Social home page Coder Social logo

telegrammessageanalysisbot's Introduction

Telegram Message Analysis Bot

This is a Telegram bot server which provides some basic message statistics and analysis functions.
It interacts with users in a command-line-like way. Messages starting with '/' or '>' are considered as command.

For example, if you haven't viewed a chat for long time and found there're 1000 unread messages, probably you just want to get a summary instead of viewing the messages one by one. Now you can try the 'keyword' command. Send:

>keyword -n 1000
You will get a response like the following:
Keywords of latest 1000 messages
------
11/16 03:34 EST /goto__m_292331
food, restaurant, steak, burger, beef, chicken, sauce, fish,
------
11/19 19:42 EST /goto__m_295920
code, java, c++, python, programming, bug, test, release, build,
------
...

Note: It has NOT been optimized for high QPS, but works well for limited number of chats which is configurable through a chat id whitelist in the config file.

Functionality

Main commands:

  1. rank
    Computes a rank based on the number of messages of the given type each user sent.
  2. history
    Outputs the history of chat titles and commands.
  3. keyword
    Computes the keywords of messages in the given time range.
  4. network
    Outputs an image to show the reply relationships between users.
  5. goto
    Outputs a message which replies to the message you want to go to.
  6. chat
    Chat with the bot.

How to deploy

  1. Clone and import this project to your machine.

  2. Set up database:
    This project uses MySQL database.
    Please install MySQL and create a database for the bot.
    To make it compatible with emoji, please set char set and collation to utf8mb4.
    Fill the database URL, username and password to config.ini.
    If you don't want to use MySQL, you can create a new class which implements DatabaseInterface and replace MySQLDatabase.

  3. Set up NLP server:
    This project has dependency on NLPUtil (client) which is used for 'keyword' command.
    Build the library and import it to this project, as well as set up NLPUtil server (see the README of NLPUtil).
    Fill the NLPUtil server host and port to config.ini.
    If you don't want to use this library, you can create a new class which implements NLPInterface and replace NLPUtilClientWrapper.
    If you don't want to enable 'keyword' command at all, simply remove the corresponding register statement from code.

  4. Set up Graphviz:
    This project has dependency on Graphviz which is used for generating images for 'network' command.
    Please install Graphviz and fill the binary path to config.ini.
    If you don't want to use this library, you can create a new class which implements GraphVisualizationInterface and replace Graphviz.
    If you don't want to enable 'network' command at all, simply remove the corresponding register statement from code.

  5. Set up Turing Robot:
    This project has dependency on Turing Robot which is used as chat bot API for 'chat' command.
    Please register Turing Robot and fill the API key to config.ini.
    If you don't want to use Turing Robot API, you can create a new class which implements ChatBotInterface and replace TuringRobot.
    If you don't want to enable 'chat' command at all, simply remove the corresponding register statement from code.

  6. Build the bot as runnable jar.

  7. Create a new telegram bot (see the instructions here) and fill the bot name and token to config.ini.

  8. Fill the numeric ids of the chats you want to serve into ChatWhiteList field in config.ini.

  9. Fill the rest of fields in config.ini.

  10. Start the bot server.

  11. Set up WordCounter which computes word frequency for 'keyword' function. Schedule it to run once per month.

How to use it in Telegram

Send:

>help
It will show you help information.

telegrammessageanalysisbot's People

Contributors

neoshell avatar

Watchers

 avatar  avatar

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.