Пример #1
0
 def setPermission(self,
                   auth_capability,
                   auth_recommendedlevel,
                   auth_fail_callback=None):
     """ Sets permission information for say or client commands """
     services.use('auth').registerCapability(auth_capability,
                                             auth_recommendedlevel)
     self.auth_capability = auth_capability
     self.auth_fail_callback = auth_fail_callback
Пример #2
0
   def execute(self, args):
      """
      When told to execute the function we need to pass the userid of the player who used the command
      as well as the command's arguments. We also need to determine if the player is authorized to
      use the command.
      """
      userid = es.getcmduserid()
      # No auth? No fuss.
      if not self.auth_capability is None:
         # Check whether the userid is authorized
         is_authed = services.use('auth').isUseridAuthorized(userid, self.auth_capability)
         if not is_authed:
            # If a callback has been specified for auth failure then execute that function
            if self.auth_fail_callback:
               if callable(self.auth_fail_callback):
                  self.auth_fail_callback(userid, args)
               else:
                  es.doblock(self.auth_fail_callback)
            # We have yet to inform the player they aren't authorized so we need to do it
            else:
               es.tell(userid, 'You are not authorized to use the ' + self.name + ' command.')
            return

      if callable(self.callback):
         self.callback(userid, args)
      else:
         es.server.queuecmd('es_xdoblock ' + self.callback)
Пример #3
0
   def execute(self, args):
      """
      When told to execute the function we need to pass the userid of the player who used the command
      as well as the command's arguments. We also need to determine if the player is authorized to
      use the command.
      """
      userid = es.getcmduserid()
      # No auth? No fuss.
      if not self.auth_capability is None:
         # Check whether the userid is authorized
         is_authed = services.use('auth').isUseridAuthorized(userid, self.auth_capability)
         if not is_authed:
            # If a callback has been specified for auth failure then execute that function
            if self.auth_fail_callback:
               if isinstance(self.auth_fail_callback, collections.Callable):
                  self.auth_fail_callback(userid, args)
               else:
                  es.doblock(self.auth_fail_callback)
            # We have yet to inform the player they aren't authorized so we need to do it
            else:
               es.tell(userid, 'You are not authorized to use the ' + self.name + ' command.')
            return

      if isinstance(self.callback, collections.Callable):
         self.callback(userid, args)
      else:
         es.server.queuecmd('es_xdoblock ' + self.callback)
Пример #4
0
def permissionToInteger(permission):
   """
   Converts a text permission level ('ROOT', 'ADMIN', etc) to its
   integer equivalent
   """
   if isinstance(permission, int):
      return permission
   value = services.use('auth').__getattribute__(permission)
   if isinstance(value, int):
      return value
   raise NameError, "'%s' is not a valid auth permission" % permission
Пример #5
0
def permissionToInteger(permission):
   """
   Converts a text permission level ('ROOT', 'ADMIN', etc) to its
   integer equivalent
   """
   if isinstance(permission, int):
      return permission
   value = services.use('auth').__getattribute__(permission)
   if isinstance(value, int):
      return value
   raise NameError(f"'{permission}' is not a valid auth permission")
Пример #6
0
        self.con = sqlite.connect(path)
        self.cur = self.con.cursor()
    def execute(self,sql):
        self.cur.execute(sql)
        self.con.commit()
    def query(self,sql):
        self.cur.execute(sql)
        return self.cur.fetchall()
    def close(self):
        self.con.close()


xaauthmanage = xa.register(info.basename)
lang = xaauthmanage.language.getLanguage()

auth = services.use('auth')
authaddon = auth.name
if authaddon not in ('group_auth','basic_auth'):
    raise ImportError('Unsupported Auth Provider!')

prefix = '#green[AuthManage]#default'

###################################################
#      EVENTS

def load():
    es.dbgmsg(1,'*****authmanage load')
    xaauthcmd = xaauthmanage.addCommand('xa_auth', _sendmain, 'manage_auth', 'ADMIN')
    xaauthcmd.register('say')
   
    if authaddon == 'group_auth':
Пример #7
0
 def setPermission(self, auth_capability, auth_recommendedlevel, auth_fail_callback=None):
    """ Sets permission information for say or client commands """
    services.use('auth').registerCapability(auth_capability, auth_recommendedlevel)
    self.auth_capability    = auth_capability
    self.auth_fail_callback = auth_fail_callback
Пример #8
0
""" Load the dictionary """
dictPath = os.path.join( es.getAddonPath( info.basename ), "data.db" )
if os.path.isfile(dictPath):
	fileStream = open(dictPath, 'r')
	mapDicts   = cPickle.load(fileStream)
	fileStream.close()
	
""" Load the languages """
langPath = os.path.join( es.getAddonPath( info.basename ), "strings.ini" )
if os.path.isfile(langPath):
	text = langlib.Strings(langPath)
	
""" Set up an auth check service, to return whether or not the user is authed. """
if services.isRegistered('auth'):
	auth_service = services.use('auth')
	auth_service.registerCapability('surftimer', auth_service.ADMIN)
	isAuthed = lambda x: auth_service.isUseridAuthorized(x, 'surftimer')
else:
	isAuthed = lambda x: False
	
def load():
	""" If the script is loaded halfway through a load, ensure the delays start """
	if str(currentMap):
		es_map_start({'mapname':str(currentMap)})
	es.regsaycmd('!restart', 'surftimer/restart', 'Teleport back to start')
		
def unload():
	del started[:]
	players.clear()
	fileStream = open(dictPath, 'w')
Пример #9
0
    def execute(self, sql):
        self.cur.execute(sql)
        self.con.commit()

    def query(self, sql):
        self.cur.execute(sql)
        return self.cur.fetchall()

    def close(self):
        self.con.close()


xaauthmanage = xa.register(info.basename)
lang = xaauthmanage.language.getLanguage()

auth = services.use('auth')
authaddon = auth.name
if authaddon not in ('group_auth', 'basic_auth'):
    raise ImportError('Unsupported Auth Provider!')

prefix = '#green[AuthManage]#default'

###################################################
#      EVENTS


def load():
    es.dbgmsg(1, '*****authmanage load')
    xaauthcmd = xaauthmanage.addCommand('xa_auth', _sendmain, 'manage_auth',
                                        'ADMIN')
    xaauthcmd.register('say')
Пример #10
0
def player_spawn(event_var):
  user = int(event_var['userid'])
  auth = services.use("auth")
  if not auth.isUseridAuthorized(user, "can_spawn2"):
    es.sexec(user, "kill")
Пример #11
0
def load():
  auth = services.use("auth")
  auth.registerCapability("can_spawn2", auth.ADMIN)
Пример #12
0
def player_spawn(event_var):
    user = int(event_var['userid'])
    auth = services.use("auth")
    if not auth.isUseridAuthorized(user, "can_spawn2"):
        es.sexec(user, "kill")
Пример #13
0
def load():
    auth = services.use("auth")
    auth.registerCapability("can_spawn2", auth.ADMIN)
Пример #14
0
cfg.text("*****************************************************************")
cfg.text("*** %s Config" %info.name) 
cfg.text("*****************************************************************")
cfg.text(' ')
SA_DURATION = cfg.cvar('sa_duration', 11, 'Duration of one advert to stay. Minimum is 11!')
SA_DEFAULT_COLOR = cfg.cvar('sa_default_color', '#red', 'Default color if none was specified for an advert. List of colors below.')
SA_REFRESH_ON_ROUND = cfg.cvar('sa_refresh_on_round', 0, 'Refresh advert list every round')
cfg.text(' ')
cfg.text('List of available colors:')
for color in sorted(COLORS):
   cfg.text(" -" + color)
cfg.write()
cfg.execute()

if services.isRegistered('auth'):
   auth_service = services.use('auth')
   auth_service.registerCapability('add_ad_permission', auth_service.ADMIN)
   isAuthed = lambda x: auth_service.isUseridAuthorized(x, 'add_ad_permission')
else:
   isAuthed = lambda x: False

def load():
   global adverts
   adverts = getAdverts()
   printAdverts()

def unload():
   gamethread.cancelDelayed('adverts_delay')
   cmdlib.unregisterClientCommand('add_advert')
   cmdlib.unregisterClientCommand('delete_advert')
   cmdlib.unregisterServerCommand('add_advert')