1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-02 17:46:45 +02:00

Add topic lock command and callbacks

This commit is contained in:
jfreegman
2021-11-16 11:47:51 -05:00
parent 5851cb2dd8
commit 0b32b985f1
9 changed files with 85 additions and 1 deletions

View File

@ -89,6 +89,7 @@ static const char *group_cmd_list[] = {
"/join",
"/kick",
"/list",
"/locktopic",
"/log",
"/mod",
"/myid",
@ -790,6 +791,23 @@ static void groupchat_onGroupPrivacyState(ToxWindow *self, Tox *m, uint32_t grou
write_to_log(tmp_event, "The founder", ctx->log, true);
}
static void groupchat_onGroupTopicLock(ToxWindow *self, Tox *m, uint32_t groupnumber, TOX_GROUP_TOPIC_LOCK topic_lock)
{
ChatContext *ctx = self->chatwin;
if (self->num != groupnumber || !get_groupchat(groupnumber)) {
return;
}
const char *tlock_str = topic_lock == TOX_GROUP_TOPIC_LOCK_ENABLED ? "locked" : "unlocked";
line_info_add(self, true, NULL, NULL, SYS_MSG, 1, BLUE, "-!- The group founder has %s the topic.", tlock_str);
char tmp_event[MAX_STR_SIZE];
snprintf(tmp_event, sizeof(tmp_event), " %s the topic.", tlock_str);
write_to_log(tmp_event, "The founder", ctx->log, true);
}
static void groupchat_onGroupPassword(ToxWindow *self, Tox *m, uint32_t groupnumber, const char *password,
size_t length)
{
@ -1662,6 +1680,7 @@ static ToxWindow *new_group_chat(Tox *m, uint32_t groupnumber, const char *group
ret->onGroupTopicChange = &groupchat_onGroupTopicChange;
ret->onGroupPeerLimit = &groupchat_onGroupPeerLimit;
ret->onGroupPrivacyState = &groupchat_onGroupPrivacyState;
ret->onGroupTopicLock = &groupchat_onGroupTopicLock;
ret->onGroupPassword = &groupchat_onGroupPassword;
ret->onGroupNickChange = &groupchat_onGroupNickChange;
ret->onGroupStatusChange = &groupchat_onGroupStatusChange;