gnuweeb / gnuweebbot Goto Github PK
View Code? Open in Web Editor NEWHigh-performance bot Telegram, running on Linux environment, written in C.
License: GNU General Public License v2.0
High-performance bot Telegram, running on Linux environment, written in C.
License: GNU General Public License v2.0
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
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 the second pass (just one passed) when I have pull request #7
This is normal things or CI code need improvement?
simple, make a pull request
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 :
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 loggingFine, 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?
Deploy a translator API and implement translate module for the bot. We will utilize a scraper to gather the data from Google Translate.
/^(?:\/|\!|\~|\.)?(?: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
) may contain auto
. Which means it uses auto detect mechanism in the Google Translate API./^(?:\/|\!|\~|\.)?(?:t[rl])(?:\s(\S+)\s(\S+))?$/Usi
$1
is the code of source language.$2
is the code of target language.$1
and $2
may be omitted, when they're omitted, the default value for $1
is auto
and $2
is en
.tr en id good morning
, the bot must reply it with selamat pagi
.Good morning
, then User B replies to the message with tr en ja
, the bot must reply user A message's with おはようございます
.This addresses https://t.me/GNUWeeb/489077
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.
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.
!
or /
or .
or ~
.!
, but you can use other prefixes mentioned above.!ban
is a command for admin to ban a user (reply to user's message to be banned).!unban
is a command for admin to unban a user (reply to user's message to be unbanned).!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.!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.!mute
is a command for admin to mute user (reply to user's message to be muted).!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.!unmute
is a command for admin to unmute user (reply to user's message to be unmuted).!pin
is a command for admin to pin a message (reply to message to be pinned).!unpin
is a command for admin to unpin a message (reply to message to be unpinned).!del
or !delete
is a command for admin to delete a message (reply to message to be deleted).!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.!delvote
is a command for normal user to vote a message deletion.Calling getChatAdministrators()
every time privilege check is done is too expensive w.r.t. latency.
N
.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);
}
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.
reply_to
recursive parser.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
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.