Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Register classes
- QueryAccept::classes::register
- // Initialize events
- QueryAccept::events::init
- // Load configuration
- QueryAccept::config::load
- // Set options
- option boolShowMinimizedDebugWindow 1
- // Register the classes
- alias(QueryAccept::classes::register)
- {
- // Create an array with all the classes of our addon.
- // In this way it's easy to add or remove classes to registering routine
- %classes[] = $array()
- //QueryAccept::classes::database, \
- //QueryAccept::classes::gui::options)
- // Scan the array and register the classes
- for(%i=0; %i < $length(%classes[]); %i++)
- {
- if($classdefined("%classes[%i]"))
- {
- objects.killclass %classes[%i]
- }
- eval %classes[%i]
- }
- }
- // Initialize events
- alias(QueryAccept::events::init)
- {
- event(OnKVIrcStartup,"QueryAccept")
- {
- // Load the catalogue (translation) file "queryaccept" from the path provided
- trload queryaccept $file.localdir("locale/QueryAccept")
- QueryAccept::config::load
- }
- event(OnChannelMessage,"QueryAccept_onmsg")
- {
- }
- }
- // Load configuration
- alias(QueryAccept::config::load)
- {
- // If the class ConfHandler is not defined, register all classes we have
- if(!$classdefined(QueryAccept::classes::ConfHandler))
- {
- QueryAccept::classes::register
- }
- // Sets some variables
- // %QueryAcceptConfig = $new(QueryAccept::classes::ConfHandler)
- %QueryAcceptConfigPath = $file.localdir(config/scripts/QueryAccept)
- // Open the configuration file and sets the section "general"
- %c = $config.open(%QueryAcceptConfigPath/QueryAccept.kvc,"r")
- config.setsection %c whitelist
- %Whitelist = $array()
- %a = $config.keylist(%c)
- foreach(%key, %a) {
- %Whitelist[$length(%a)] = $config.read(%c, %key)
- }
- // Store the value of the key "Key" in the global variable %Key
- config.close %c
- }
- alias(QueryAccept::config::save) {
- %c = $config.open(%QueryAcceptConfigPath/QueryAccept.kvc)
- config.setsection %c whitelist
- for(%i=0;%i<$length(%Whitelist);%i++)
- config.write %c %i %Whitelist[%i]
- }
- alias(QueryAccept::isWhitelisted) {
- for(%i = 0; %i < $length(%Whitelist); %i++) {
- if ($0 == %Whitelist[%i]) return true
- }
- return
- }
- alias(querywhitelist) {
- if ($0 == "add") {
- %Whitelist[$length[%Whitelist]] = $1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement