/* \method account.authorized \param group The ACL group that should be checked for. \param action The action in the given ACL group that should be checked. \return True if the account may perform the given action. False otherwise. \description Checks if the account may perform a given action based on its ACL. */ static PyObject* wpAccount_authorized( wpAccount* self, PyObject* args ) { if ( !checkArgStr( 0 ) || !checkArgStr( 1 ) ) { PyErr_BadArgument(); return 0; } QCString group = getArgStr( 0 ).latin1(); QCString action = getArgStr( 1 ).latin1(); if ( self->account->authorized( group, action ) ) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
/*! Returns the custom tag passed */ static PyObject* wpMulti_gettag( wpMulti* self, PyObject* args ) { if( !self->pMulti || self->pMulti->free ) { Py_INCREF( Py_None ); return Py_None; } if( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); cVariant value = self->pMulti->getTag( key ); if( value.type() == cVariant::String ) { QString strValue = value.asString(); if( !strValue.isNull() ) return PyString_FromString( strValue.latin1() ); else return PyString_FromString( "" ); } else if( value.type() == cVariant::Int ) return PyInt_FromLong( value.asInt() ); Py_INCREF( Py_None ); return Py_None; }
/*! Sets a custom tag */ static PyObject* wpMulti_settag( wpMulti* self, PyObject* args ) { if( !self->pMulti || self->pMulti->free ) return PyFalse; if( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) || ( !checkArgStr( 1 ) && !checkArgInt( 1 ) ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); self->pMulti->removeTag( key ); if( checkArgStr( 1 ) ) self->pMulti->setTag( key, cVariant( QString( getArgStr( 1 ) ) ) ); else if( checkArgInt( 1 ) ) self->pMulti->setTag( key, cVariant( (int)getArgInt( 1 ) ) ); return PyTrue; }
/* \method socket.hastag \description Check if the socket has a certain custom tag attached to it. \return True if the tag is present. False otherwise. \param name The name of the tag. */ static PyObject* wpSocket_hastag( wpSocket* self, PyObject* args ) { if ( !self->pSock ) return PyFalse(); if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = getArgStr( 0 ); return self->pSock->tags().has( key ) ? PyTrue() : PyFalse(); }
/*! Checks if a certain tag exists */ static PyObject* wpMulti_hastag( wpMulti* self, PyObject* args ) { if( !self->pMulti || self->pMulti->free ) return PyFalse; if( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); return self->pMulti->getTag( key ).isValid() ? PyTrue : PyFalse; }
/* \method socket.sendweblink \description Send an url to the client and open it in the players webbrowser. \param url The url that should be sent. */ static PyObject* wpSocket_sendweblink( wpSocket* self, PyObject* args ) { if ( !self->pSock ) return PyFalse(); if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString url = getArgStr( 0 ); self->pSock->sendWeblink( url ); Py_RETURN_NONE; }
/* \method socket.deltag \description Deletes a tag attached to the socket. \param name The name of the tag. */ static PyObject* wpSocket_deltag( wpSocket* self, PyObject* args ) { if ( !self->pSock ) return PyFalse(); if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = getArgStr( 0 ); self->pSock->tags().remove( key ); Py_RETURN_NONE; }
/*! Deletes a given tag */ static PyObject* wpMulti_deltag( wpMulti* self, PyObject* args ) { if( !self->pMulti || self->pMulti->free ) return PyFalse; if( !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); self->pMulti->removeTag( key ); return PyTrue; }
/* \method ai.onSpeechInput \param from A <object id="char">char</object> object for the character the text is coming from. \param text A string with the text that should be processed. \description This method sends a text with a given source to the ai engine to proces it. This could be used to force the banker engine to open the bankbox for instance. */ static PyObject* wpAI_onSpeechInput( wpAI* self, PyObject* args ) { if ( !checkArgChar( 0 ) ) return 0; if ( !checkArgStr( 1 ) ) return 0; P_CHAR pc = getArgChar( 0 ); P_PLAYER player = dynamic_cast<P_PLAYER>( pc ); if ( !player ) Py_RETURN_FALSE; QString str = getArgStr( 1 ); self->pAI->onSpeechInput( player, str.upper() ); Py_RETURN_TRUE; }
/* \method socket.gettag \description Get a custom tag attached to the socket. Please keep in mind these tags are temporary in nature. When the socket disconnects, the tag will be gone. \return None if there is no such tag, the tag value otherwise. Possible return types are: unicode (string), float, integer. \param name The name of the tag. */ static PyObject* wpSocket_gettag( wpSocket* self, PyObject* args ) { if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); cVariant value = self->pSock->tags().get( key ); if ( value.type() == cVariant::StringType ) return QString2Python( value.toString() ); else if ( value.type() == cVariant::IntType ) return PyInt_FromLong( value.asInt() ); else if ( value.type() == cVariant::DoubleType ) return PyFloat_FromDouble( value.asDouble() ); Py_RETURN_NONE; }
/* * Adds a temp effect to this multi. */ static PyObject* wpMulti_addtimer( wpMulti* self, PyObject* args ) { if( (PyTuple_Size( args ) < 3 && PyTuple_Size( args ) > 4) || !checkArgInt( 0 ) || !checkArgStr( 1 ) || !PyList_Check( PyTuple_GetItem( args, 2 ) ) ) { PyErr_BadArgument(); return NULL; } UINT32 expiretime = getArgInt( 0 ); QString function = getArgStr( 1 ); PyObject *py_args = PyList_AsTuple( PyTuple_GetItem( args, 2 ) ); cPythonEffect *effect = new cPythonEffect( function, py_args ); if( checkArgInt( 3 ) && getArgInt( 3 ) != 0 ) effect->setSerializable( true ); else effect->setSerializable( false ); effect->setDest( self->pMulti->serial() ); effect->setExpiretime_ms( expiretime ); TempEffects::instance()->insert( effect ); return PyTrue; }