Code Monkey home page Code Monkey logo

gnuweebbot's People

Contributors

aliwoto avatar ammarfaizi2 avatar irvanmalik48 avatar komori-k avatar nrudesu avatar sprtcrnbry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gnuweebbot's Issues

Group for this bot?

Since @ammarfaizi2 has left and deleted the TDD group, this bot does not have any home for doing its work anymore.

We downgraded @ammarfaizi2 permission because he left without warning or further discussion, it's must be easy to upgrade again

  • We wait for this problem solved and get best conclusions
  • Create dev Telegram group for discuss about this project separated to main group tend to off topics
  • Return @ammarfaizi2 ownership

[core] Implement Database and Event Logger

Before the first stable release, I want to implement database and event logger as fundamental core. Utilizing database is mandatory for saving state like number of user warnings, admin cache, user cache, notes, etc.

CI not report second build status

Intro

CI not report the second pass (just one passed) when I have pull request #7
This is normal things or CI code need improvement?

How to Reproduce This

simple, make a pull request

[CI] Any Linter or Indent checker?

One of contributor often forget about indentations rule.

So, I think we need CI for this project, but new problem occur. We need pick linter software is suitable and set it to our configuration or just make own indent checker

TODO :

  • Research about linter software
  • Make linter software + add some option alternative
  • Waiting for review or pick external lint software
  • Then add it to CI

[module] Add a command delete message from archive

On Tue, 26 October 2021 at 21:28:18 GMT+07, Ammar Faizi wrote:

On Tue, 26 October 2021 at 21:20:59 GMT+07, んる wrote:

asal deleted message auto dihapus kalau ada request delete ane mau
pakai logging

Fine, gini, kita bisa buat bot untuk request delete pesan dan
permintaan dilayani otomatis.

Caranya login via bot. Yang login harus akun Telegram yang ngirim
pesan yang hendak didelete.

Cara deletenya pakai command + ID reference dari web archive (nanti ku
buat + fitur searchnya, biar gampang nyari pesan yang mau dihapus).

Future work:
Bisa dibikin dashboard akun GNU/Weeb member, akses via web, login SSO
pakai akun Telegram. Dari situ mau manage hal lain juga lebih gampang,
mau hapus juga bisa dari situ.

Good?

[module] Translate API

Deploy a translator API and implement translate module for the bot. We will utilize a scraper to gather the data from Google Translate.

Translate feature specification

  1. Translate command is any message that matches the following pattern:
/^(?:\/|\!|\~|\.)?(?:t[rl])\s(\S+)\s(\S+)\s(.+)$/Usi
  • $1 is the code of source language.
  • $2 is the code of target language.
  • $3 is the text written in source language to be translated to target language.
  1. Available languages can be seen here: https://github.com/ammarfaizi2/GoogleTranslate/blob/master/README.md
  2. Source language ($1) may contain auto. Which means it uses auto detect mechanism in the Google Translate API.

Extra (translate replied message)

  1. Translate replied message command is any message that replies another message and matches the following pattern:
/^(?:\/|\!|\~|\.)?(?:t[rl])(?:\s(\S+)\s(\S+))?$/Usi
  • $1 is the code of source language.
  • $2 is the code of target language.
  • Replied message is the text written in source language to be translated to target language.
  • $1 and $2 may be omitted, when they're omitted, the default value for $1 is auto and $2 is en.

Examples

  1. User A sends a message tr en id good morning, the bot must reply it with selamat pagi.
  2. User A sends a message Good morning, then User B replies to the message with tr en ja, the bot must reply user A message's with おはようございます.

TODO List

[module] Create quiz module

Create quiz module with score system. The mechanism is like waifu bot that we have on @GNUWeeb telegram group. The bot randomly sends a quiz, if a user answers it correctly, then accumulate fair point for the corresponding question.

[module] Admin module for group management

This bot needs to have group management features. So let's create it. In order to gets the bot working properly, the bot must be a group administrator with sufficient permissions.

Module Specification

  • Command in this module is any message that starts with ! or / or . or ~.
  • In this document, we will demonstrate any command starts with !, but you can use other prefixes mentioned above.

Privileged commands

  1. !ban is a command for admin to ban a user (reply to user's message to be banned).
  2. !unban is a command for admin to unban a user (reply to user's message to be unbanned).
  3. !kick is a command for admin to kick a user (reply to user's message to be kicked). The difference with !ban is that the kicked user is free to rejoin the group after they gets kicked. No unban action needs to be performed.
  4. !warn is a command for admin to warn user (reply to user's message to be warned). The number of warnings will be stored in the bot database. When it reaches the maximum number, the warned user will be banned from the group.
  5. !mute is a command for admin to mute user (reply to user's message to be muted).
  6. !tmute is a command for admin to mute user temporarily. This command requires an argument. The argument is a number to determine how long the user is going to be muted. It can use suffix s for second, m for minute, d for day, w for week. By default, if suffix is not provided, then the unit will be second.
  7. !unmute is a command for admin to unmute user (reply to user's message to be unmuted).
  8. !pin is a command for admin to pin a message (reply to message to be pinned).
  9. !unpin is a command for admin to unpin a message (reply to message to be unpinned).
  10. !del or !delete is a command for admin to delete a message (reply to message to be deleted).

Normal user commands

  1. !report is a command for normal user to report an event to the admins. All admins will be notified via private message if they have started the bot.
  2. !delvote is a command for normal user to vote a message deletion.

Caveat: This document has not finished.

[core] Create admin cache to reduce privilege check latency

Calling getChatAdministrators() every time privilege check is done is too expensive w.r.t. latency.

Workaround

  • Check for privilege every message count reaches a number which is divisible by N.

Pseudo Code

if (message_count % N == 0) {
  updateAdminCache();
}


/*
 * Privilege check function
 */
bool checkPrivileged(uint64_t user_id, int64_t group_id) {
   if (checkPrivilegeFromCache(user_id, group_id)) 
      return true;
   updateAdminCache();
   return checkPrivilegeFromCache(user_id, group_id);
}

[core] Reply to message abstraction

Short technical explanation

Currently, reply_to field for any event is set to NULL as we haven't created any mechanism to parse replied message.

Sample of event can be taken from text message:

struct tgev {
    /* 
     * We need to hold the JSON object to release
     * the resource, as it holds the reference
     * to `const char *`.
     *
     * It hurts the performance if we allocate
     * new memory and copy it. So let it here.
     */
    json_object *json;

    uint64_t    update_id;
    tgev_type_t type;
    struct_pad(0, 4);
    union {
        struct tgev_gif     msg_gif;
        struct tgev_text    msg_text;
        struct tgev_photo   msg_photo;
        struct tgev_sticker msg_sticker;
    };
};

struct tgev_text {
    uint64_t               msg_id;
    struct tgevi_from      from;
    struct tgevi_from      forward_from;
    const char             *fwd_sender_name;
    struct tgevi_chat      chat;
    struct tgevi_chat      sender_chat;
    time_t                 date;
    time_t                 forward_date;
    const char             *text;
    uint16_t               entity_c; /* How many entities[n] there are? */
    struct tgevi_entity    *entities;
    struct tgev            *reply_to;
    bool                   is_forwarded;
    bool                   is_unknown_fwd;
};

reply_to contains a pointer struct tgev, which means if the JSON keys are completely identical, we can use recursive call inside event parser.

TODO List

  • Make sure replied message has identical JSON keys.
  • Implement reply_to recursive parser.

[core] Implement io_uring

I am going to replace epoll with io_uring, however io_uring syscall is only available for Linux 5.1+, hence I will not drop the epoll support, I will just make a dispatcher to detect kernel version at runtime.

IOW, we can say like this:

if (linux_version >= 5.1) {
   // use io_uring
} else {
   // fallback to epoll
}

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.