-// $Id: ChangeLog,v 1.166 2009/05/16 07:47:23 danielaustin Exp $ //
+// $Id: ChangeLog,v 1.167 2009/06/09 15:40:28 mrbean_ Exp $ //
+2009-06-09 MrBean
+ * mod.cservice/ACCESSCommand.cc:
+ * mod.cservice/cservice.cc:
+ * mod.cservice/CHANINFOCommand.cc:
+ * mod.cservice/levels.h:
+ * mod.cservice/responses.h:
+ * mod.cservice/LOGINCommand.cc:
+ * mod.cservice/MODINFOCommand.cc:
+ * mod.cservice/SHOWCOMMANDSCommand.cc:
+ * mod.cservice/sqlLevel.cc:
+ * mod.cservice/sqlLevel.h: Added invite on LOGIN,
+ to toggle: /msg X modinfo #chan INVITE <ON|OFF>
+
2009-05-16 Isomer
* mod.ccontrol/FORCECHANGLINECommand.cc:
* mod.ccontrol/FORCEGLINECommand.cc:
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ACCESSCommand.cc,v 1.49 2007/11/05 11:18:32 kewlio Exp $
+ * $Id: ACCESSCommand.cc,v 1.50 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <string>
#include "cservice_config.h"
#include "Network.h"
-const char ACCESSCommand_cc_rcsId[] = "$Id: ACCESSCommand.cc,v 1.49 2007/11/05 11:18:32 kewlio Exp $" ;
+const char ACCESSCommand_cc_rcsId[] = "$Id: ACCESSCommand.cc,v 1.50 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
bot->Notice(theClient,
bot->getResponse(theUser, language::channel_automode_is).c_str(),
bot->SQLDb->GetValue(i, 0).c_str(),
- autoMode.c_str()
- );
+ autoMode.c_str());
if( suspend_expires > bot->currentTime() )
{
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: CHANINFOCommand.cc,v 1.61 2008/11/12 20:45:42 mrbean_ Exp $
+ * $Id: CHANINFOCommand.cc,v 1.62 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <string>
#include "dbHandle.h"
#include "cservice_config.h"
-const char CHANINFOCommand_cc_rcsId[] = "$Id: CHANINFOCommand.cc,v 1.61 2008/11/12 20:45:42 mrbean_ Exp $" ;
+const char CHANINFOCommand_cc_rcsId[] = "$Id: CHANINFOCommand.cc,v 1.62 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
{
int maxLogins = theUser->getMaxLogins();
stringstream ss;
- ss << maxLogins
- << ends ;
+ ss << maxLogins;
+// << ends ;
if (maxLogins > 1)
flagsSet += "MAXLOGINS=" + ss.str() + " ";
- }
+
+ stringstream autoInviteQuery;
+
+ autoInviteQuery << "SELECT channel_id from levels"
+ << " where user_id = " << theUser->getID()
+ << " and flags & "
+ << sqlLevel::F_AUTOINVITE
+ << " > 0"
+ << " and deleted = 0"
+ << ends;
+
+ #ifdef LOG_SQL
+ elog << "CHANINFO::sqlQuery> "
+ << autoInviteQuery.str().c_str()
+ << endl;
+ #endif
+
+
+ if( !bot->SQLDb->Exec(autoInviteQuery, true ) )
+// if( PGRES_TUPLES_OK != status )
+ {
+
+ elog << "CHANINFO> SQL Error: "
+ << bot->SQLDb->ErrorMessage()
+ << endl ;
+ return false;
+ }
+ if(bot->SQLDb->Tuples() > 0)
+ {
+ flagsSet+= "INVITE ";
+ }
+
+ }
/* set 'NONE' if no flags */
if (flagsSet.size() == 0)
flagsSet = "NONE ";
bot->outputChannelAccesses(theClient, theUser, tmpUser, 500);
}
+
return true;
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: LOGINCommand.cc,v 1.66 2008/11/12 20:45:42 mrbean_ Exp $
+ * $Id: LOGINCommand.cc,v 1.67 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <string>
#include "cservice.h"
#include "md5hash.h"
#include "responses.h"
+#include "levels.h"
#include "networkData.h"
#include "cservice_config.h"
#include "Network.h"
#include "ip.h"
-const char LOGINCommand_cc_rcsId[] = "$Id: LOGINCommand.cc,v 1.66 2008/11/12 20:45:42 mrbean_ Exp $" ;
+const char LOGINCommand_cc_rcsId[] = "$Id: LOGINCommand.cc,v 1.67 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
/* If the autoop flag isn't set in this record */
if (!(resultPtr->flags & sqlLevel::F_AUTOOP) &&
- !(resultPtr->flags & sqlLevel::F_AUTOVOICE))
+ !(resultPtr->flags & sqlLevel::F_AUTOVOICE) &&
+ !(resultPtr->flags & sqlLevel::F_AUTOINVITE))
{
continue;
}
continue;
}
+
/*
- * Check if the channel is NOOP.
- * N.B: If the channel is strictop, we op them.
- * They've just logged in! :P
+ * Check if they're already opped.
*/
- if(theChan->getFlag(sqlChannel::F_NOOP))
+ Channel* netChan = Network->findChannel(theChan->getName());
+ if (!netChan)
{
continue;
}
+
/*
- * Check they aren't banned < 75 in the chan.
+ * Don't attempt to op/invite if we're not in the channel, or not op'd.
*/
- sqlBan* tmpBan = bot->isBannedOnChan(theChan, theClient);
- if( tmpBan && (tmpBan->getLevel() < 75) )
+ ChannelUser* tmpBotUser = netChan->findUser(bot->getInstance());
+ if (!tmpBotUser)
+ {
+ continue;
+ }
+
+ if (!theChan->getInChan() || !tmpBotUser->getMode(ChannelUser::MODE_O))
{
continue;
}
/*
- * Check if they're already opped.
+ * Would probably be wise to check they're not suspended too :)
+ * (*smack* Ace)
*/
- Channel* netChan = Network->findChannel(theChan->getName());
- if (!netChan)
+ if(resultPtr->suspend_expires > bot->currentTime() )
{
continue;
}
ChannelUser* tmpChanUser = netChan->findUser(theClient) ;
if(!tmpChanUser)
{
+ //The user is not in the channel, lets see if their autoinvite is on and act upon it
+ if (resultPtr->flags & sqlLevel::F_AUTOINVITE)
+ {
+ int level = bot->getEffectiveAccessLevel(theUser, theChan, true);
+ if(level >= level::invite)
+ {
+ bot->Invite(theClient,netChan);
+ }
+ }
continue;
}
/*
- * Don't attempt to op if we're not in the channel, or not op'd.
+ * Check if the channel is NOOP.
+ * N.B: If the channel is strictop, we op them.
+ * They've just logged in! :P
*/
- ChannelUser* tmpBotUser = netChan->findUser(bot->getInstance());
- if (!tmpBotUser)
- {
- continue;
- }
-
- if (!theChan->getInChan() || !tmpBotUser->getMode(ChannelUser::MODE_O))
+ if(theChan->getFlag(sqlChannel::F_NOOP))
{
continue;
}
/*
- * Would probably be wise to check they're not suspended too :)
- * (*smack* Ace)
+ * Check they aren't banned < 75 in the chan.
*/
- if(resultPtr->suspend_expires > bot->currentTime() )
+ sqlBan* tmpBan = bot->isBannedOnChan(theChan, theClient);
+ if( tmpBan && (tmpBan->getLevel() < 75) )
{
continue;
}
bot->Op(netChan, theClient);
}
}
- else
+ else if (resultPtr->flags & sqlLevel::F_AUTOVOICE)
{
if(!tmpChanUser->getMode(ChannelUser::MODE_V))
{
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: MODINFOCommand.cc,v 1.19 2003/06/28 01:21:20 dan_karrels Exp $
+ * $Id: MODINFOCommand.cc,v 1.20 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <string>
#include "levels.h"
#include "responses.h"
-const char MODINFOCommand_cc_rcsId[] = "$Id: MODINFOCommand.cc,v 1.19 2003/06/28 01:21:20 dan_karrels Exp $" ;
+const char MODINFOCommand_cc_rcsId[] = "$Id: MODINFOCommand.cc,v 1.20 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
bot->incStat("COMMANDS.MODINFO");
StringTokenizer st( Message ) ;
-if( st.size() < 5 )
+if( st.size() < 4 )
{
Usage(theClient);
return true;
}
-const string command = string_upper(st[2]);
-if ((command != "ACCESS") && (command != "AUTOMODE"))
+string command = string_upper(st[2]);
+if ((command != "ACCESS") && (command != "AUTOMODE") && (command != "INVITE"))
+ {
+ Usage(theClient);
+ return true;
+ }
+if(command != "INVITE" && st.size() < 5 )
{
Usage(theClient);
return true;
}
-
/*
* Fetch the sqlUser record attached to this client. If there isn't one,
* they aren't logged in - tell them they should be.
return false;
}
+int required_level = level::modinfo;
+if (command == "INVITE")
+ {
+ required_level = level::modinfo_autoinvite;
+ }
/*
* Check the user has sufficient access on this channel.
*/
int level = bot->getEffectiveAccessLevel(theUser, theChan, true);
-if (level < level::modinfo)
+if (level < required_level)
{
bot->Notice(theClient,
bot->getResponse(theUser,
return false;
}
+if(command == "INVITE")
+ { //Handle modinfo INVITE
+ if(st[1] == "*")
+ { //Admin channel?
+ bot->Notice(theClient,"It is a mistake to think you can solve any major problems just with potatoes.");
+ return false;
+ }
+ if(string_upper(st[3]) == "ON")
+ { //Time to enable INVITE option
+ sqlLevel* aLevel = bot->getLevelRecord(theUser, theChan);
+ aLevel->setFlag(sqlLevel::F_AUTOINVITE);
+ aLevel->commit();
+
+ bot->Notice(theClient,
+ bot->getResponse(theUser,
+ language::automode_invite,
+ string("Set INVITE on login %s for channel %s")).c_str(),
+ theChan->getName().c_str(),"ON");
+
+ return false;
+ }
+ else if(string_upper(st[3]) == "OFF")
+ {
+ sqlLevel* aLevel = bot->getLevelRecord(theUser, theChan);
+ aLevel->removeFlag(sqlLevel::F_AUTOINVITE);
+ aLevel->commit();
+
+ bot->Notice(theClient,
+ bot->getResponse(theUser,
+ language::automode_invite,
+ string("Set INVITE on login %s for channel %s")).c_str(),
+ theChan->getName().c_str(),"OFF");
+
+ return false;
+ }
+ Usage(theClient);
+ return false;
+ }
+
/*
* Check the person we're trying to change actually exists.
*/
if (command == "AUTOMODE")
{
+
+ if(st[1] == "*")
+ { //Admin channel?
+ bot->Notice(theClient,"If there's anything more important than my ego around, I want it caught and shot now.");
+ return false;
+ }
+
/*
* Check we aren't trying to change someone with access higher
* than ours. Also, make sure we can't change someone else's MODINFO
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SHOWCOMMANDSCommand.cc,v 1.29 2005/12/05 17:32:15 kewlio Exp $
+ * $Id: SHOWCOMMANDSCommand.cc,v 1.30 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <string>
#include "levels.h"
#include "responses.h"
-const char SHOWCOMMANDSCommand_cc_rcsId[] = "$Id: SHOWCOMMANDSCommand.cc,v 1.29 2005/12/05 17:32:15 kewlio Exp $" ;
+const char SHOWCOMMANDSCommand_cc_rcsId[] = "$Id: SHOWCOMMANDSCommand.cc,v 1.30 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
static const char* lvl_500_cmds = "\002Level 500\002: part";
static const char* lvl_450_cmds = "\002Level 450\002: join set%s*";
-static const char* lvl_400_cmds = "\002Level 400\002: adduser clearmode* modinfo remuser";
+static const char* lvl_400_cmds = "\002Level 400\002: adduser clearmode* modinfo+ remuser";
static const char* lvl_100_cmds = "\002Level 100\002: op deop invite suspend unsuspend";
static const char* lvl_75_cmds = "\002Level 75\002: ban* unban*";
static const char* lvl_50_cmds = "\002Level 50\002: kick%s topic";
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: cservice.cc,v 1.293 2009/02/04 17:09:39 denspike Exp $
+ * $Id: cservice.cc,v 1.294 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <new>
RegisterCommand(new DEVOICECommand(this, "DEVOICE", "<#channel> [nick] [nick] ..", 3));
RegisterCommand(new ADDUSERCommand(this, "ADDUSER", "<#channel> <username> <access>", 8));
RegisterCommand(new REMUSERCommand(this, "REMUSER", "<#channel> <username>", 4));
-RegisterCommand(new MODINFOCommand(this, "MODINFO", "<#channel> [ACCESS <username> <level>] [AUTOMODE <username> <NONE|OP|VOICE>]", 6));
+RegisterCommand(new MODINFOCommand(this, "MODINFO", "<#channel> [ACCESS <username> <level>] [AUTOMODE <username> <NONE|OP|VOICE>] [INVITE <ON|OFF>]", 6));
RegisterCommand(new SETCommand(this, "SET", "[#channel] <variable> <value> or, SET <invisible> <ON|OFF> or, SET LANG <language> or, SET MAXLOGINS <max-logins>.", 6));
RegisterCommand(new INVITECommand(this, "INVITE", "<#channel>", 2));
RegisterCommand(new TOPICCommand(this, "TOPIC", "<#channel> <topic>", 4));
xClient::DoCTCP(theClient, CTCP,
"Undernet P10 Channel Services II ["
__DATE__ " " __TIME__
- "] Release 1.3");
+ "] Release 1.4");
}
else if(Command == "PROBLEM?")
{
stringstream channelsQuery;
string channelList ;
- channelsQuery << "SELECT channels.name,levels.access FROM levels,channels "
+ channelsQuery << "SELECT channels.name,levels.access,levels.flags FROM levels,channels "
<< "WHERE levels.channel_id = channels.id AND channels.registered_ts <> 0 AND levels.user_id = "
<< theUser->getID()
<< " AND levels.access >= "
string chanName ;
string chanAccess ;
+ unsigned int flags;
if( !SQLDb->Exec(channelsQuery, true ) )
// if( PGRES_TUPLES_OK != status )
for(unsigned int i = 0; i < SQLDb->Tuples(); i++)
{
- chanName = SQLDb->GetValue(i,0);
+ flags = atoi(SQLDb->GetValue(i, 2));
+ if(flags & sqlLevel::F_AUTOINVITE)
+ {
+ chanName = "\002" + SQLDb->GetValue(i,0) + "\002";
+ } else {
+ chanName = SQLDb->GetValue(i,0);
+ }
chanAccess = SQLDb->GetValue(i,1);
+
// 4 for 2 spaces, 2 brackets + comma.
if ((channelList.size() + chanName.size() + chanAccess.size() +5) >= 450)
{
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: levels.h,v 1.30 2005/09/29 15:21:56 kewlio Exp $
+ * $Id: levels.h,v 1.31 2009/06/09 15:40:29 mrbean_ Exp $
*/
#ifndef __LEVELS_H
-#define __LEVELS_H "$Id: levels.h,v 1.30 2005/09/29 15:21:56 kewlio Exp $"
+#define __LEVELS_H "$Id: levels.h,v 1.31 2009/06/09 15:40:29 mrbean_ Exp $"
namespace gnuworld {
const int status = 1;
const int force = 1; // And by definition, unforce.
-
+ const int modinfo_autoinvite = 1;\r
+
const int voice = 25;
const int devoice = 25;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: responses.h,v 1.20 2005/12/27 13:27:59 kewlio Exp $
+ * $Id: responses.h,v 1.21 2009/06/09 15:40:29 mrbean_ Exp $
*/
#ifndef __RESPONSES_H
-#define __RESPONSES_H "$Id: responses.h,v 1.20 2005/12/27 13:27:59 kewlio Exp $"
+#define __RESPONSES_H "$Id: responses.h,v 1.21 2009/06/09 15:40:29 mrbean_ Exp $"
namespace gnuworld
{
const int invalid_option = 158;
const int is_service_bot = 159;
const int is_coder_rep = 160;
- const int is_coder_contrib = 161;
+ const int is_coder_contrib = 161;
const int is_coder_devel = 162;
const int is_coder_senior = 163;
- const int is_also_an_ircop = 164;
+ const int is_also_an_ircop = 164;
const int ban_added = 165;
const int ban_list_empty = 166;
- const int already_on_chan = 167;
+ const int already_on_chan = 167;
const int ircops_only_cmd = 168;
const int im_not_op = 169;
const int rpl_ignorelist = 170;
const int no_adduser = 173;
const int noadduser_on = 174;
const int noadduser_off = 175;
- const int auth_failed_logins = 176;
- const int max_failed_logins = 177;
+ const int auth_failed_logins = 176;
+ const int max_failed_logins = 177;
+ const int automode_invite = 178;
const int greeting = 9998;
const int motd = 9999;
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlLevel.cc,v 1.17 2007/08/28 16:10:12 dan_karrels Exp $
+ * $Id: sqlLevel.cc,v 1.18 2009/06/09 15:40:29 mrbean_ Exp $
*/
#include <sstream>
#include "cservice_config.h"
const char sqlLevel_h_rcsId[] = __SQLLEVEL_H ;
-const char sqlLevel_cc_rcsId[] = "$Id: sqlLevel.cc,v 1.17 2007/08/28 16:10:12 dan_karrels Exp $" ;
+const char sqlLevel_cc_rcsId[] = "$Id: sqlLevel.cc,v 1.18 2009/06/09 15:40:29 mrbean_ Exp $" ;
namespace gnuworld
{
const sqlLevel::flagType sqlLevel::F_FORCED = 0x04 ;
const sqlLevel::flagType sqlLevel::F_AUTOVOICE =0x08 ;
const sqlLevel::flagType sqlLevel::F_ONDB = 0x10 ;
+const sqlLevel::flagType sqlLevel::F_AUTOINVITE = 0x20;
sqlLevel::sqlLevel(dbHandle* _SQLDb)
:channel_id(0),
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlLevel.h,v 1.18 2007/08/28 16:10:12 dan_karrels Exp $
+ * $Id: sqlLevel.h,v 1.19 2009/06/09 15:40:29 mrbean_ Exp $
*/
#ifndef __SQLLEVEL_H
-#define __SQLLEVEL_H "$Id: sqlLevel.h,v 1.18 2007/08/28 16:10:12 dan_karrels Exp $"
+#define __SQLLEVEL_H "$Id: sqlLevel.h,v 1.19 2009/06/09 15:40:29 mrbean_ Exp $"
#include <string>
#include <ctime>
static const flagType F_FORCED; // Deprecated.
static const flagType F_AUTOVOICE;
static const flagType F_ONDB; // Deprecated.
+ static const flagType F_AUTOINVITE;
/*
* Methods to get data atrributes.