Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: os_SVSKILL  (Read 8035 times)

0 Members and 1 Guest are viewing this topic.

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
os_SVSKILL
« on: December 31, 2010, 12:49:40 AM »

Code: [Select]
/***************************************************************************************/
/* Anope Module : os_svskill.c : v1.0.2                                                */ 
/* Trystan Scott Lee                                                                   */
/* trystan@nomadirc.net                                                                */
/*                                                                                     */
/* Adds OperServ SVSKILL command                                                       */
/*   This module allows services admins to forcefully                                  */
/*   disconnect a user without KILL quit message.                                      */
/*                                                                                     */
/* ChangeLog:                                                                          */
/*  1.00 - Works                                                                       */
/*  1.01 - Customizable help messages.                                                 */
/*         Option to require a quit message to be specified.                           */
/*  1.02 - took over coding this module from Strike                                    */
/*       - Moved a some config options to config file                                  */
/*       - ran indent against the code                                                 */
/*       - switched to moduleGetLastBuffer()                                           */
/*       - removed redunent security check of service admin in do_svskil()             */
/*       - removed configuration option for SVSKILL_SYNTAX                             */
/*       - moved all lang stuff to new api format                                      */
/*                                                                                     */
/* This program is free software; you can redistribute it and/or modify it under the   */
/* terms of the GNU General Public License as published by the Free Software           */
/* Foundation; either version 1, or (at your option) any later version.                */
/*                                                                                     */
/*  This program is distributed in the hope that it will be useful, but WITHOUT ANY    */
/*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A    */
/*  PARTICULAR PURPOSE.  See the GNU General Public License for more details.          */
/*                                                                                     */
/***************************************************************************************/

#include "module.h"
#define AUTHOR "Trystan"
#define VERSION "1.02"

#define LNG_NUM_STRINGS 6

#define LNG_SVSKILL_SYNTAX_MSG 0
#define LNG_SVSKILL_SYNTAX_NOMSG 1
#define LNG_SVSKILL_HELP            2
#define LNG_SVSKILL_HELP_NOMSG 3
#define LNG_SVSKILL_HELP_SIMPLE 4
#define LNG_SVSKILL_OPER          5
   
int do_svskill(User * u);
void modHelp_svskill(User * u);
int modHelp_svskill_full(User * u);
int do_reload(int argc, char **argv);
void load_config(void);
int DontKillOpers;
int RequireQuitMsg;
void my_add_languages(void);

int AnopeInit(int argc, char **argv)
{
    Command * c;
EvtHook *hook;

    c = createCommand("SVSKILL", do_svskill, is_services_admin, -1, -1,
                       -1, -1, -1);
    moduleAddCommand(OPERSERV, c, MOD_HEAD);

    hook = createEventHook(EVENT_RELOAD, do_reload);
    moduleAddEventHook(hook);

    moduleAddHelp(c, modHelp_svskill_full);
    moduleSetOperHelp(modHelp_svskill);

    my_add_languages();

    alog("[os_svskill] Module successfully loaded.");
    moduleAddAuthor(AUTHOR);
    moduleAddVersion(VERSION);
    moduleSetType(THIRD);

    load_config();
    return MOD_CONT;
}

void AnopeFini(void)
{
    alog("Unloading os_svskill.so");
}

int do_reload(int argc, char **argv)
{
    load_config();
    return MOD_CONT;
}

void load_config(void)
{
int i;

    Directive confvalues[][1] = {
{{"SVSKillDontKillOpers", {{PARAM_INT, PARAM_RELOAD, &DontKillOpers}}}},
        {{"SVSKillRequireQuitMsg", {{PARAM_INT, PARAM_RELOAD, &RequireQuitMsg}}}}
    };

for (i = 0; i < 2; i++)
    moduleGetConfigDirective(confvalues[i]);

    if (debug)
        alog("debug: [os_svskill] Set config vars: SVSKillDontKillOpers=%s SVSKillRequireQuitMsg=%s", (DontKillOpers ? "yes" : "no"), (RequireQuitMsg ? "yes" : "no"));
}

void modHelp_svskill(User * u)
{
    if (is_services_admin(u)) {
         moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_HELP_SIMPLE);
    }
    return;
}

int modHelp_svskill_full(User * u)
{
    if (is_services_admin(u)) {
        if (RequireQuitMsg) {
            moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_SYNTAX_MSG);
        } else {
            moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_SYNTAX_NOMSG);
        }       
    }
    return MOD_CONT;
}

int do_svskill(User * u)
{
    char *buffer = moduleGetLastBuffer();
    char *killed;
    char *quitmsg;
    User *u2, *tmp_u;

    killed = myStrGetToken(buffer, ' ', 0);
    quitmsg = myStrGetToken(buffer, ' ', 1);

    if (!killed) {
        if (RequireQuitMsg) {
            moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_SYNTAX_MSG);
        } else {
            moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_SYNTAX_NOMSG);
        }
        return MOD_STOP;
    }

    if (RequireQuitMsg && !quitmsg) {
        moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_SYNTAX_MSG);
        return MOD_STOP;
    }
   
    u2 = finduser(killed);
    if (!u2) {
        notice(s_OperServ, u->nick, "User %s does not exist.", killed);
        return MOD_STOP;
    }
   
    if (is_oper(u2) && DontKillOpers) {
        moduleNoticeLang(s_OperServ, u, LNG_SVSKILL_OPER);
        alog("%s: %s has attempted to SVSKILL oper %s", s_OperServ,
              u->nick, u2->nick);
        return MOD_STOP;
    }
    tmp_u = u2;
    if (quitmsg) {
            send_cmd(s_OperServ, "SVSKILL %s :%s", u2->nick, quitmsg);
    } else {
            send_cmd(s_OperServ, "SVSKILL %s :Quit", u2->nick);
    }
    del_session(tmp_u->host);
    notice(s_OperServ, u->nick, "User %s has been svskilled.", u2->nick);
    return MOD_STOP;
}

void my_add_languages(void)
{
    /* English (US) */
    char *langtable_en_us[] = {
        "   \002SVSKILL <NICK> <QUITMSG>\002",
        "   \002SVSKILL <NICK>\002",

        "Syntax: \002SVSKILL <NICK> <QUITMSG>\002\n"
        "Allows services admins to forcefully disconnect a user from\n"
        "the network without a kill quit message. The QUITMSG\n"
        "chosen is displayed as a user's standard quit message.",
        /* 4 */
        "Syntax: \002SVSKILL <NICK>\002\n"
        "Allows services admins to forcefully disconnect a user from\n"
        "the network without a kill quit message.",
        /* 5 */
        "    SVSKILL Forcefully disconnect a user with a standard quit",
        "You may not svskill other IRC operators.",
    };

    moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
}
OKay, i have a problem, and ive tried anything in my small brain  to fix this, but i dont know how. So im gonna ask u gurus. As this is my fiirst time doing C#.
Quote
/msg OperServ svskill Romeo "Connection Reset By Peer"
    [18:15] Closing Link: Romeo
[c-98-198-22-215.hsd1.tx.comcast.net] services.skyn3t.net ("Connection)
-
[18:15] * Disconnected
[/list]
Now how do i fix it to where it will let my complete message show. As u can see it only showed the first word and thats it. I also tried to make it to where it wont kick oper.  But heck, that didnt seem to work either. So can someone please help me.
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

LEthaLity

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 307
    • LEthaLity
Re: os_SVSKILL
« Reply #1 on: December 31, 2010, 12:08:59 PM »

Change the following (line 135)
Code: [Select]
quitmsg = myStrGetToken(buffer, ' ', 1);TO
Code: [Select]
quitmsg = myStrGetTokenRemainder(buffer, ' ', 1);
That will accept everything after the nick whereas myStrGetToken only takes the first part of the string.

Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: os_SVSKILL
« Reply #2 on: December 31, 2010, 02:36:38 PM »

Quote
As this is my fiirst time doing C#.
No wonder if you think you are working in C#.. anope 1.8 and its modules are written in C  ::)
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #3 on: December 31, 2010, 06:54:03 PM »

Thnk u, works like a charm!!
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #4 on: January 03, 2011, 07:36:09 PM »

One last question yall.. on there, it says something about being able to restrict it from working on opers. So opers cannot use it on each other. At least, thats how i thought i read it..  i looks like its asking me, but i dont know where to answer it at. so can someone help me with that last bit. After that, this module is A-1.. Thanks
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

LEthaLity

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 307
    • LEthaLity
Re: os_SVSKILL
« Reply #5 on: January 03, 2011, 07:41:28 PM »

looks like it's done by adding  SVSKillDontKillOpers "yes"  to services.conf
« Last Edit: January 03, 2011, 07:43:40 PM by LEthaLity »
Logged

katsklaw

  • Supporter
  • Anope User
  • Offline Offline
  • Posts: 537
Re: os_SVSKILL
« Reply #6 on: January 03, 2011, 11:41:15 PM »

Looks like there is another optional directive too called SVSKillRequireQuitMsg that is also a yes/no question.
Logged

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #7 on: January 04, 2011, 01:38:02 AM »

yes, thats what i was kinda implying to. should i just delete the "/no" and let it just say yes. and it should work.. maybe i shoulda just tried that out first before asking. But. Im gonna try that, if that doest work, what should i do. And whats a good program to download to edit these modules? as i dont know what is a stupid question. cause i know nothing about the language or how to edit it.
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

katsklaw

  • Supporter
  • Anope User
  • Offline Offline
  • Posts: 537
Re: os_SVSKILL
« Reply #8 on: January 04, 2011, 02:20:59 AM »

Those are config values that you add to services.conf, not in the module it's self.
Logged

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #9 on: January 04, 2011, 03:04:40 AM »

oh... wow.. i didnt know that.. ok
************
im guessing i can just put this anywhere..
so add this to .conf like this.. right?
[os_svskill]
Set config vars:
SVSKillDontKillOpers=%s SVSKillRequireQuitMsg=%s",
(DontKillOpers ? "yes"), (RequireQuitMsg ? "no"));
« Last Edit: January 04, 2011, 05:01:52 AM by Romeo »
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: os_SVSKILL
« Reply #10 on: January 04, 2011, 07:35:13 AM »

if you need 'SVSKillDontKillOpers' than simply add "SVSKillDontKillOpers" to the conf... nothing complicated about that..  ???
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #11 on: January 04, 2011, 04:13:13 PM »

OKay.. i decided to paste it in the OperServ Configuration area in the services.conf
This is the last lil bit of that area + what i added to it, so u have a clue what i did.
Code: [Select]
# SessionAutoKillExpiry <time> [OPTIONAL]
#
# Sets the expiry time for autokills added for hosts that need to be
# AKILLed as controlled by the MaxSessionKill option.
#
# If not given, the default value is 30 minutes.

SessionAutoKillExpiry 30m


# AddAkiller [OPTIONAL]
#     Adds the nickname of the Operator issuing an AKILL to the kill reason.
#
AddAkiller

# OSOpersOnly [RECOMMENDED]
#     If this is defined, only IRC Operators will be permitted to use
#     OperServ, regardless of module based command access restrictions.

OSOpersOnly

# this is so svs wont kill opers
#
SVSKillRequireQuitMsg  "No"
SVSKillDontKillOpers "Yes"
I didnt paste the whole Operserv Config area, as its alot.
 Now, i did /os reload in mirc, and got this.
Code: [Select]
[10:05] <Global> OperServ: Romeo5k: reload
[10:05] <Global> services.conf:1365: SVSKillDontKillOpers: Expected an integer for parameter 1
[10:05] <Global> services.conf:1364: SVSKillRequireQuitMsg: Expected an integer for parameter 1
[10:05] <Global> os_info: Reloading configuration directives...
[10:05] <Global> os_info: OSInfoDBName is not defined in Services configuration file, using default os_info.db
[10:05] <Global> os_info: Directive OSInfoDBName loaded (os_info.db)...
[10:05] <Global> [os_shun]: Reloading configuration directives...
So now im like.. wtf just happened, and what did i break?
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: os_SVSKILL
« Reply #12 on: January 04, 2011, 04:18:57 PM »

you are doing it wrong.. it should be
Code: [Select]
SVSKillDontKillOpers 1
SVSKillRequireQuitMsg 1
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

Romeo

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 31
Re: os_SVSKILL
« Reply #13 on: January 04, 2011, 04:46:26 PM »

thank you.. .. im done.. works like a charm...:-)
ty all for help..
n sorry for not knowing this stuff.
Logged
running Unreal 3.2.10.1, Anope 1.9.9 on Ubuntu Server

katsklaw

  • Supporter
  • Anope User
  • Offline Offline
  • Posts: 537
Re: os_SVSKILL
« Reply #14 on: January 05, 2011, 01:44:27 AM »

DOH! I should have caught that because of the declarations in the source, my bad.
Logged
Pages: [1]   Go Up