Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: 1 ... 4 5 [6] 7 8 ... 10
 51 
 on: February 23, 2023, 02:44:57 PM 
Started by The Myth Lives - Last post by The Myth Lives
So, I've been using the cs_autolimit module (code below), but I'm facing the following issues:
  • Normal users (even with founder status) can't use the SET command
  • Normal users (even with founder status) can't use the SHOW command

Module
Code: [Select]
/* ------------------------------------------------------------------------------------------------
 *  Name: | CS_AUTOLIMIT
 *  Author: | Fill
 *  Version: | 0.0.1 (Anope 2.0.1)
 *  Date: | 02/2015
 * ------------------------------------------------------------------------------------------------
 * This module adds a command to ChanServ (AUTOLIMIT) to automatically manage a channel user limit.
 * (mode +l)
 *
 * This is a rewrite of the original cs_autolimit for Anope 2.0.1
 * ------------------------------------------------------------------------------------------------
 * 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.
 * ------------------------------------------------------------------------------------------------
 *  To use, place this in your services.conf):
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ START CONF OPTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module {
       name = "cs_autolimit";
}
command { service = "ChanServ"; name = "AUTOLIMIT"; command = "chanserv/autolimit"; }
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END CONF OPTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 */

/* Do NOT touch anything below unless you really know what you're getting into.
 * Changing the code without knowing what you're doing can CRASH services and / or the IRCd.
 * You have been warned.
 */

#include "module.h"

using namespace std;

struct ChanAlimitInfo;
typedef map<Anope::string, ChanAlimitInfo *> alimit_map;
static alimit_map alimits_db;

#define MIN_ALIMIT_AMT 1
#define MAX_ALIMIT_AMT 100
#define MIN_ALIMIT_INTERVAL 2
#define MAX_ALIMIT_INTERVAL 300
#define TIMER_INTERVAL 5

struct ChanAlimitInfo : Serializable {
Anope::string chan_name;
Anope::string author;
unsigned amount;
time_t interval;
time_t last_set;

ChanAlimitInfo() : Serializable("ChanAlimitInfo") { }
~ChanAlimitInfo() {
alimit_map::iterator iter = alimits_db.find(chan_name.lower());
if (iter != alimits_db.end() && iter->second == this)
alimits_db.erase(iter);
}

void Serialize(Serialize::Data &data) const anope_override
{
data["chan"] << chan_name;
data["author"] << author;
data["amount"] << amount;
data["interval"] << interval;
data["last_set"] << last_set;
}

static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
{
Anope::string chan;
Anope::string chan_std;

data["chan"] >> chan;

chan_std = chan.lower();

ChanAlimitInfo *cai;
if (obj)
cai = anope_dynamic_static_cast<ChanAlimitInfo *>(obj);
else
{
ChanAlimitInfo* &info = alimits_db[chan_std];
if (!info)
info = new ChanAlimitInfo();
cai = info;
}

cai->chan_name = chan;
data["author"] >> cai->author;
data["amount"] >> cai->amount;
data["interval"] >> cai->interval;
data["last_set"] >> cai->last_set;

if (!obj)
alimits_db[chan_std] = cai;

return cai;
}
};

class CommandCSAutoLimit : public Command
{
 public:
CommandCSAutoLimit(Module *creator, const Anope::string &sname = "chanserv/autolimit") : Command(creator, sname, 1, 4)
{
this->SetDesc(_("Automatically manages the channel user limit"));
this->SetSyntax(_("<channel> SET <amount> <interval>"));
this->SetSyntax(_("<channel> DEL"));
this->SetSyntax(_("<channel> SHOW"));
this->SetSyntax(_("LIST (opers only)"));
}

void Execute(CommandSource &source, const vector<Anope::string> &params) anope_override
{

if (!params[0].equals_ci("LIST")) {
if (params.size() < 2) {
this->OnSyntaxError(source, params[0]);
return;
}
if (!IRCD->IsChannelValid(params[0])) {
source.Reply(_("Invalid channel name: %s\r\n"), params[0].c_str());
return;
}
ChannelInfo *ci = ChannelInfo::Find(params[0]);
if (ci == NULL) {
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
return;
}
bool has_access = AccessCheck(source, ci);
if (!has_access) {
source.Reply(_("Access denied.\r\n"));
return;
}
if (params[1].equals_ci("SET")) {
if (params.size() < 4) {
this->OnSyntaxError(source, params[0]);
return;
}
unsigned amount;
time_t interval;
try {
        amount = convertTo<unsigned>(params[2]);
interval = convertTo<time_t>(params[3]);
}
catch (const ConvertException &)
{
this->OnSyntaxError(source, "SET");
return;
}
if (amount < MIN_ALIMIT_AMT || amount > MAX_ALIMIT_AMT) {
source.Reply(_("Invalid increase amount value. Please specify a value in the range %d-%d\r\n"), MIN_ALIMIT_AMT, MAX_ALIMIT_AMT);
return;
}
if (interval < MIN_ALIMIT_INTERVAL || interval > MAX_ALIMIT_INTERVAL) {
source.Reply(_("Invalid time interval. Please specify a value in the range %d-%d\r\n"), MIN_ALIMIT_INTERVAL, MAX_ALIMIT_INTERVAL);
return;
}

DoAlimitSet(source, ci, params[0], amount, interval);

} else if (params[1].equals_ci("DEL")) {
if (!DoAlimitDel(ci, params[0])) {
source.Reply(_("Channel %s not found on the AUTOLIMIT database.\r\n"), params[0].c_str());
return;
} else {
source.Reply(_("Removed %s from the AUTOLIMIT list.\r\n"), params[0].c_str());
}
} else if (params[1].equals_ci("SHOW")) {
alimit_map::const_iterator it = alimits_db.find(params[0].lower());
if (it == alimits_db.end()) {
source.Reply(_("Channel %s not found on the AUTOLIMIT database.\r\n"), params[0].c_str());
return;
}

ReportEntry(source, it->second);

} else {
this->OnSyntaxError(source, params[0]);
return;
}
} else {
if (!source.GetUser()->HasMode("OPER")) {
source.Reply(_("Access denied.\r\n"));
return;
}
if (alimits_db.begin() == alimits_db.end())
source.Reply(_("No entries.\r\n"));
for (alimit_map::const_iterator it = alimits_db.begin(); it != alimits_db.end(); it++)
ReportEntry(source, it->second);
}

ostringstream oss;
for (vector<Anope::string>::const_iterator it = params.begin(); it != params.end(); it++)
oss << *it << " ";
Log(LOG_ADMIN, source, this) << oss.str();
}

bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" \r\n");
source.Reply(_("This command let's channel admins configure automatic\r\n"
       "adjustment of the user limit (mode +l). A user is considered\r\n"
       "to be a channel admin if he/she can modify the channel's access\r\n"
       "list.\r\n \r\n"
       "The \002SET\002 command is used to add a new channel to the list\r\n"
       "of managed channels, or to update a channel's current settings.\r\n"
       "This command will make services set the channel limit (+l) every\r\n"
       "<interval> seconds. The limit set is equal to the number of users\r\n"
       "at that time, plus <amount>.\r\n"
       "Please note that choosing a large interval or a small amount may result\r\n"
       "in users being unable to join your channel during or after netsplits.\r\n"
       "For starters, a reasonable value might be an interval of 30 seconds\r\n"
       "with an amount of 5 or 10.\r\n \r\n"
       "\002DEL\002 deletes a channel from the managed channels list. Services\r\n"
       "will remove the limit mode and stop managing the channel.\r\n \r\n"
       "\002SHOW\002 is used to see the current settings for a specific channel.\r\n \r\n"
       "The command \002LIST\002 shows a full list of every channel managed by\r\n"
       "services and its settings regarding the user limit mode. This command is\r\n"
       "available for IRCOps only.\r\n \r\n"
       "IRCOps can use any of these commands in any channel."));
return true;
}

private:
void ReportEntry(CommandSource &source, const ChanAlimitInfo *entry) {
source.Reply(_("%s (<usercount>+%u every %ld seconds) - Last edited by: %s\r\n"),
     entry->chan_name.c_str(), entry->amount, entry->interval, entry->author.c_str());
}

bool AccessCheck(CommandSource &source, ChannelInfo *ci) {
return source.GetUser()->HasMode("OPER") || source.AccessFor(ci).HasPriv("chanserv/access/modify");
}

void DoAlimitSet(CommandSource &source, ChannelInfo *ci, const Anope::string &chan, unsigned amount, time_t interval) {

Anope::string chan_name = chan.lower();
ChanAlimitInfo *&cinfo = alimits_db[chan_name];

if (cinfo == NULL) {
cinfo = new ChanAlimitInfo();
cinfo->chan_name = chan;
}

cinfo->author = source.GetUser()->nick;
cinfo->amount = amount;
cinfo->interval = interval;
cinfo->last_set = Anope::CurTime;

alimits_db[chan_name] = cinfo;

if (ci->c != NULL) {
ostringstream oss;
oss << ci->c->users.size()+cinfo->amount;
ci->c->SetMode(NULL, "LIMIT", oss.str(), false);
}

source.Reply(_("Channel user limit for %s will be set to <usercount>+%d every %ld seconds."), chan.c_str(), amount, interval);
}

bool DoAlimitDel(ChannelInfo *ci, const Anope::string &chan) {
alimit_map::iterator it = alimits_db.find(chan.lower());
if (it == alimits_db.end())
return false;
delete it->second;
if (ci->c != NULL)
ci->c->RemoveMode(NULL, "LIMIT", "", false);
return true;
}
};

class SetChanLimitTimer : public Timer
{
public:
SetChanLimitTimer(Module *this_module, long interval) : Timer(this_module, interval, Anope::CurTime, true) { }

void Tick(time_t now) anope_override {
for (alimit_map::const_iterator it = alimits_db.begin(); it != alimits_db.end(); it++) {
ChanAlimitInfo *cai = it->second;
if (cai->last_set + cai->interval <= Anope::CurTime) {
ChannelInfo *ci = ChannelInfo::Find(cai->chan_name);
if (ci == NULL || ci->c == NULL)
continue;
ostringstream oss;
oss << ci->c->users.size()+cai->amount;
ci->c->SetMode(NULL, "LIMIT", oss.str(), false);
cai->last_set = Anope::CurTime;
}
}
}
};

class CSAutoLimit : public Module
{
public:
CSAutoLimit(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, THIRD), commandcsautolimit(this),
  chanlimittimer(this, TIMER_INTERVAL),
  alimitinfo_type("ChanAlimitInfo", ChanAlimitInfo::Unserialize)
{
this->SetAuthor("Fill <filipe@codinghighway.com>");
this->SetVersion("0.0.1");
}

EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) anope_override
{
Anope::string chan = ci->name.lower();
alimit_map::iterator it = alimits_db.find(chan);
if (it == alimits_db.end())
return EVENT_CONTINUE;
delete it->second;
if (ci->c != NULL)
ci->c->RemoveMode(NULL, "LIMIT", "", false);
return EVENT_CONTINUE;
}

void OnChannelCreate(Channel *c) anope_override
{
Anope::string chan = c->name.lower();
alimit_map::iterator it = alimits_db.find(chan);
if (it == alimits_db.end())
return;
ostringstream oss;
oss << c->users.size()+it->second->amount;
c->SetMode(NULL, "LIMIT", oss.str(), false);
}

private:
CommandCSAutoLimit commandcsautolimit;
SetChanLimitTimer chanlimittimer;
Serialize::Type alimitinfo_type;
};

MODULE_INIT(CSAutoLimit)

Iff someone could fix this properly, I'd be very grateful.

Cheers

 52 
 on: February 21, 2023, 07:07:11 AM 
Started by Me - Last post by Lord255
hello.
its only for 1 user.

 53 
 on: February 21, 2023, 12:15:16 AM 
Started by Me - Last post by Me
Hi all !

I would like to know if it is possible to send a memo to several recipients in one command. I know you can do it to all registered nicknames with /msg memoserv send all, but if for example I want to send a memo to three people /msg memoserv send nickname1 nickname2 nickname3 my message? Is this possible with a particular separator character or not?

Thank you.

 54 
 on: February 19, 2023, 09:14:00 PM 
Started by Amine - Last post by Lord255
you need to set a log for a chan for example to see the host requests.

like:

Code: [Select]
/*
 * when someone execute the following commands, it will be "logged" to the given channel
 */
log
{
   bot = "HostServ"
   target = "#chnnelname"
   commands = "hostserv/request hostserv/activate"
}

on the how to login to operserv:
/msg operserv login


 55 
 on: February 19, 2023, 08:23:29 PM 
Started by Amine - Last post by Amine
bonjour,
je suis nouveau parmi vous sur le forum et sur irc, j'ai un serveur irc unrealircd 6 avec anope 2 je voudrais gérer les commandes des utilisateurs de vhost et moi autant qu'un ircop je reçois pas les notifications pourtant mes fichiers de configuration sont configurés normalement .
2- comment se loger en service root? :-\ :-\ :-\ :-\
merci d'avance ;) ;) ;) ;)

 56 
 on: February 19, 2023, 08:16:50 PM 
Started by Amine - Last post by Amine
bonjour,
je suis nouveau p

 57 
 on: February 11, 2023, 06:09:43 PM 
Started by Arno - Last post by Arno
Hi,

When trying to setup an IRC network the following error occurs:

Attempting to connect to uplink #1 192.168.s.s (192.168.s.s), port 7000
Successfully connected to uplink #1 192.168.s.s:7000
Lost connection from uplink #1 (192.168.s.s:7000): Connection reset by peer
Check that you have loaded m_spanningtree.so on InspIRCd, and are not connecting Anope to an SSL enabled port without configuring SSL in Anope (or vice versa)

In services.conf on 192.168.c.c (IRC server IRC clients connect to)

uplink
{
...
ssl = no
...
}

In services.conf on 192.168.s.s (Anope services server)
uplink
{
...
host = 192.168.s.s
ssl = no
...
}

All servers are on same local subnet.
loaded m_spanningtree.so on InspIRCd, Yes

How can this error be solved?

 58 
 on: February 01, 2023, 02:22:45 PM 
Started by Goofyseeker3 - Last post by Goofyseeker3
The nickserv/chanserv text should automatically reflect the number of days expiring set in the configuration.
Now it says 14/21 days expiration, even if days is commented out and  ns_no_expire / cs_no_expire has been defined in the defaults.

Where is this text located (under which variable) or constructed? not in the example conflict files, at least.

also: (side note) the ./bin/service should have a crontab auto-install option just like unrealircd (ie "./bin/service croncheck").
no, there is no ~/services/data/example.chk file, or you just have old documentation on the wiki.

 59 
 on: February 01, 2023, 01:11:52 PM 
Started by OpEn - Last post by Goofyseeker3
I would (did) install ssmtp as the default sendmail alternatives, then config that to use whatever SMTP server you have, hosted or external.

additional question: how would you configure the sender name in the (nickserv) email, not only the email address, by using "Sender<sender@domain.com>".

 60 
 on: January 27, 2023, 07:41:14 PM 
Started by sys - Last post by sys
Hello, guys! This is module for BotServ fantasy command in channel #vhost.
Is it posiable someone make me any changes. I need before host to be set to be checked is it exist? If is exist will not gonna set it, if is not exist will be set to the user.

-----ANOPE-2.0.12-----

/* BotServ vhost function
 *
 * Requires Fantasy setting to be on to work using in channel
 * command !vhost <host>.
 *
 * This sets a TEMPORARY vhost.  If the user wants a pernanent
 * vhost they should use the normal vhost request system in
 * hostserv.
 *
 *
 *
 * You need to set
 *    /chanserv levels #channel FANTASIA 0
 * to allow anyone in the active channel to issue the command.
 *
 *
 * ***** Configuration:  *****
 *
 * add the folloing to your botserv config file:

module
{
        name = "bs_fantasy_vhost";
        vHostRestricted = "admin ircop suck fuck shit damn test";
        vHostChannel = "#help";
}
command { service = "BotServ"; name = "VHOST"; command = "botserv/vhost"; }
fantasy { name = "VHOST"; command = "botserv/vhost"; }
 
 *
 * vHostChannel = "#help"   
 *   ^^^--- only allow it to work in this channel
 *
 * vHostRestricted = "space speperated list of prohibited words"
 *   ^^^--- Prohibit these words from appearing.  Note, these will match
 *          within other words as well.
 *
 * if vHostRestricted is empty, by defalt, only "admin" and "ircop" are protected.
 * if vHostRestricted beginxgs with "none" then nothing is protected.
 *
 * *****  Example:  *****
 *
 * vHostRestricted = "admin ircop damn turn jerk suck";
 *
 * This would prevent any vhost mask that contained admin, ircop, damn, turn, jerk, or suck.
 * Examples:
 *  !vhost I.am.an.admin
 *  !vhost Ircops.are.idiots
 *  !vhost damn.the.torpedos
 *  !vhost turn.up.the.volume
 *  !vhost you.are.akk.jerks
 *  !vhost you.are.suckers
 *
 * These would be prevented from being set by the example line above.
 *
 */

#include "module.h"

class CommandBSVhost : public Command
{

   std::vector<Anope::string> defaults;
   int vHostRestrictedNr;

 private:

        bool isvalidchar(char c)
        {               
                if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
                        return true;
                return false;
        }     

 public:
   CommandBSVhost(Module *creator) : Command(creator, "botserv/vhost", 1, 2)
   {
      this->SetDesc(_("Enable a temporary vhost."));
      this->SetSyntax(_("\037host name\037"));
   }

   void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
   {
      const Anope::string &vhost = params[0];
      const Anope::string &vhost2 = params.size() > 1 ? params[1] : "";
      const Anope::string &onlychan = Config->GetModule("bs_fantasy_vhost")->Get<const Anope::string>("vHostChannel","#help");
      User *u = source.GetUser();
      const NickAlias *na = NickAlias::Find(u->nick);
      const Anope::string &nid = u->GetIdent();
      Anope::string target = "";
      Anope::string chan = "";
      Anope::string host = "";
      Anope::string user = "";
      spacesepstream(Config->GetModule("bs_fantasy_vhost")->Get<const Anope::string>("vHostRestricted","")).GetTokens(defaults);
      if (defaults.empty())
      {
         defaults.push_back("ircop");
         defaults.push_back("admin");
      }
      else if (defaults[0].equals_ci("none"))
         defaults.clear();
      vHostRestrictedNr = defaults.size();
      if (vhost[0] == '#')
      {
         chan = vhost.c_str();
         target = vhost2.c_str();
      }
      else
      {
         target = vhost.c_str();
      }
      if (!chan.empty())
      {
         if(chan.equals_ci(onlychan.c_str()) != 1)
         {
            source.Reply(_("You can only issue this command in %s"),onlychan.c_str());
            return;
         }
      }
       size_t a = target.find('@');
      if (a == Anope::string::npos)
         host = target.c_str();
      else
      {
         user = target.substr(0, a);
         host = target.substr(a + 1);
      }
      if (host.empty())
      {
         this->OnSyntaxError(source, "");
         return;
      }
      if (!user.empty())
      {
         if (user.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen"))
         {
            source.Reply(HOST_SET_IDENTTOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("userlen"));
            return;
         }
         else if (!IRCD->CanSetVIdent)
         {
            source.Reply(HOST_NO_VIDENT);
            return;
         }
         for (Anope::string::iterator s = user.begin(), s_end = user.end(); s != s_end; ++s)
            if (!isvalidchar(*s))
            {
               source.Reply(HOST_SET_IDENT_ERROR);
               return;
            }
      }
      if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"))
      {
         source.Reply(HOST_SET_TOOLONG, Config->GetBlock("networkinfo")->Get<unsigned>("hostlen"));
         return;
      }

      if (!IRCD->IsHostValid(host))
      {
         source.Reply(HOST_SET_ERROR);
         return;
      }
      int idx;
      for (idx = 0; idx < vHostRestrictedNr; idx++)
      {
         if (target.find_ci(defaults[idx]) != Anope::string::npos)
         {
            source.Reply(_("Vhost invalid.  Containes prohibited word %s."),defaults[idx].c_str());
            return;
         }
      }

      if(na && u->Account() == na->nc && !na->HasVhost() && (u->chost.equals_ci(u->GetDisplayedHost()) || u->host.equals_ci(u->GetDisplayedHost()) ) )
      {
         Log(LOG_COMMAND,source,this) << "to set Vhost to " << target.c_str();
         IRCD->SendVhost(u, nid.c_str(), target.c_str());
         u->SetDisplayedHost(target.c_str());
         source.Reply(_("Vhost %s set."),target.c_str());
      }
      else
      {
         source.Reply(_("You already have a vhost.  You cannot set a temporary one."));
         return;
      }
   }

   bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
   {
      this->SendSyntax(source);
      source.Reply(" ");
      source.Reply(_("Allows you to set a temproary vhost."));
      return true;
   }

   
};

class BSVhost : public Module
{
   CommandBSVhost commandbsvhost;

 public:
   BSVhost(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
      commandbsvhost(this)
   {
      if (!IRCD || !IRCD->CanSetVHost)
         throw ModuleException("Your IRCd does not support vhosts");
      if (Anope::VersionMajor() < 2)
      {
         throw ModuleException("Requires version 2 of Anope.");
      }
      this->SetAuthor("Azander");
      this->SetVersion("1.0.2");
   }
};

MODULE_INIT(BSVhost)

Pages: 1 ... 4 5 [6] 7 8 ... 10