• Türkiye'nin En Güncel IRC Forumuna Hoş Geldin
    İçerikleri görebilmek ve topluluğumuza katılmak için lütfen oturum açın.

6.x Modül UnrealIRCd-6 Oylama ile Ban Sistemi

  • Konbuyu başlatan IFGT
  • Başlangıç tarihi
  • Cevaplar : 0
  • Görüntüleme : 3
🕒 Konu sahibi 32 dakika önce aktifti

IFGT

IFGT System
Katılım
2 Mar 2023
Mesajlar
263
En son yapılan şuan sitede olan.png
Merhaba​

Kanal genelinde oylama yapılarak ban atılmasına olanak sağlar.

Gerekli oy sayısını değiştirmek için REQUIRED_VOTES değerini güncelleyin.
Oylama süresini değiştirmek için VOTE_TIMEOUT değerini ayarlayın.
Ban maskesini özelleştirmek için ban komutunu değiştirin..


oylama.c
Kod:
#include "unrealircd.h"

#define REQUIRED_VOTES 3
#define VOTE_TIMEOUT 120

typedef struct {
    char *target;
    char *channel;
    int vote_count;
    char **voters;
    time_t start_time;
} ActiveVote;

static ActiveVote *active_vote = NULL;

ModuleHeader MOD_HEADER = {
    "vote_ban",
    "1.0",
    "Vote ban system",
    "fatal",
    "unrealircd-6",
};

int vote_ban_configtest(ConfigFile *cf, ConfigEntry *ce, int type, int *errs);
int vote_ban_configposttest(int *errs);
int vote_ban_configrun(ConfigFile *cf, ConfigEntry *ce, int type);

CMD_FUNC(cmd_oyla);
CMD_FUNC(cmd_evet);

MOD_INIT() {
    CommandAdd(modinfo->handle, "OYLA", cmd_oyla, 1, CMD_USER);
    CommandAdd(modinfo->handle, "EVET", cmd_evet, 1, CMD_USER);
    return MOD_SUCCESS;
}

MOD_LOAD() {
    return MOD_SUCCESS;
}

MOD_UNLOAD() {
    if (active_vote) {
        free(active_vote->target);
        free(active_vote->channel);
        free(active_vote->voters);
        free(active_vote);
    }
    return MOD_SUCCESS;
}

CMD_FUNC(cmd_oyla) {
    if (active_vote) {
        sendnotice(client, "Zaten aktif bir oylama var!");
        return;
    }

    if (parc < 2) {
        sendnotice(client, "Kullanim: /oyla nick");
        return;
    }

    active_vote = safe_alloc(sizeof(ActiveVote));
    active_vote->target = strdup(parv[1]);
    active_vote->channel = strdup(parv[parc-1]); // channel is last param
    active_vote->vote_count = 1;
    active_vote->voters = safe_alloc(sizeof(char *));
    active_vote->voters[0] = strdup(client->name);
    active_vote->start_time = TStime();

    sendto_channel(NULL, NULL, NULL, active_vote->channel,
                  "Oylama basladi! %s banlanacak. Kabul ediyorsaniz /evet yazin. (Gerekli oy: %d)",
                  active_vote->target, REQUIRED_VOTES);
}

CMD_FUNC(cmd_evet) {
    if (!active_vote) return;

    // Aynı kişi tekrar oy veremez
    for (int i = 0; i < active_vote->vote_count; i++) {
        if (!strcasecmp(active_vote->voters[i], client->name)) {
            sendnotice(client, "Zaten oy kullandiniz!");
            return;
        }
    }

    active_vote->vote_count++;
    active_vote->voters = realloc(active_vote->voters, sizeof(char *) * active_vote->vote_count);
    active_vote->voters[active_vote->vote_count-1] = strdup(client->name);

    sendto_channel(NULL, NULL, NULL, active_vote->channel,
                  "%s oy verdi. Toplam oy: %d/%d",
                  client->name, active_vote->vote_count, REQUIRED_VOTES);

    if (active_vote->vote_count >= REQUIRED_VOTES) {
        // Ban işlemi
        Channel *channel = find_channel(active_vote->channel);
        if (channel) {
            Client *target = find_client(active_vote->target, NULL);
            if (target) {
                char banmask[512];
                ircsnprintf(banmask, sizeof(banmask), "*!*@%s", target->user->realhost);
                
                do_mode(NULL, channel, 0, NULL, "+b", banmask);
                do_kick(NULL, channel, target, "Oylama sonucu banlandi.");
            }
        }
        
        // Oylamayı temizle
        for (int i = 0; i < active_vote->vote_count; i++) {
            free(active_vote->voters[i]);
        }
        free(active_vote->voters);
        free(active_vote->target);
        free(active_vote->channel);
        free(active_vote);
        active_vote = NULL;
    }
}

Modülü derleyin.

unrealircd.conf

Kod:
loadmodule "src/modules/third/oylama.so

UnrealIRCd'i yeniden başlatın.
 
Geri
Üst Alt