Comments (12)
All right, I will get tmute
and warn
part,
but before that, how bot will unmute the user after the specified time passed?
I found this code here :
tmp = do_mute(thread, reply_text, &(const tga_restrict_cm_t){
.chat_id = tge_get_chat_id(evt),
.user_id = target_uid,
.until_date = 0,
.permissions = {
.can_send_messages = is_unmute,
.can_send_media_messages = is_unmute,
.can_send_polls = is_unmute,
.can_send_other_messages = is_unmute,
.can_add_web_page_previews = is_unmute,
.can_change_info = is_unmute,
.can_invite_users = is_unmute,
.can_pin_messages = is_unmute
}
});
So, parameter until_date
will be used by telegram? It means telegram servers will unmute the user after that period of time and bot doesn't need to write the data in our database, right?
from gnuweebbot.
So, parameter until_date will be used by telegram?
Yes
It means telegram servers will unmute the user after that period of time and bot doesn't need to write the data in our database, right?
Yes, below is the explanation:
until_date
is date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.
from gnuweebbot.
Okay, then I'll work on tmute
first.
from gnuweebbot.
@ALiwoto your work will be here
GNUWeebBot/src/gwbot/modules/003_admin/admin.c
Lines 553 to 567 in 2ba55c2
For example, in that case, if an admin send a message: !tmute 2d 1h
, then the reason
variable will contain a pointer to 2d 1h
. You need to convert 2d 1h
to second unit (this will be until_date
), then pass it to do_mute()
.
Does that make sense to you?
from gnuweebbot.
@ALiwoto for the baseline, you can submit a simple parser code to me. I will co-author your name and email in the commit.
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <inttypes.h>
int main(void)
{
const char *reason = "2d 1h"; // 2 days 1 hour
time_t unix_time = 0;
/*
*
* Do something with the `reason` and `unix_time`
*
*/
printf("unix_time = %" PRIu64, (uint64_t)unix_time); // should print 176400 (2 days 1 hours in second unit)
}
from gnuweebbot.
Can you tell me what isADMIN_BITS
?
I can see the #define
part in here:
GNUWeebBot/src/gwbot/modules/003_admin/admin.c
Lines 40 to 53 in 2ba55c2
Can you explain it a bit?
from gnuweebbot.
@ammarfaizi2 Where should I put that simple parser?
Can I write it in a separated file from repo and send it to you, or I should write it in tests directory?
from gnuweebbot.
Can you tell me what is ADMIN_BITS ?
@ALiwoto ADMIN_BITS
is a collection of bits that represents privileged commands (I should have added ADM_CMD_UNPIN
, I forgot).
So, you see the enum, range from (1u << 0u)
to (1u << 8u)
are commands for admin only. We can easily test whether a command needs to be executed by a privileged user or not with single bitwise AND
against ADMIN_BITS
.
from gnuweebbot.
@ammarfaizi2 Where should I put that simple parser?
Can I write it in a separated file from repo and send it to you, or I should write it in tests directory?
You may post the code here (on the issue comment).
from gnuweebbot.
You may post the code here (on the issue comment).
Okay, I'll attach it to the next comment.
from gnuweebbot.
@ammarfaizi2 is delete message API related to this issue?
from gnuweebbot.
@komori-k yes, the !delvote
command, and we may add more commands that utilizes this API.
from gnuweebbot.
Related Issues (12)
- CI not report second build status HOT 4
- Group for this bot? HOT 3
- [module] Translate API HOT 1
- [core] Reply to message abstraction
- [CI] Any Linter or Indent checker? HOT 18
- [core] Implement Database and Event Logger
- [core] Create admin cache to reduce privilege check latency
- [module] Create quiz module
- [core] Implement io_uring
- [module] Create captcha feature to filter joining users
- [module] Add a command delete message from archive
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnuweebbot.