source: tags/start/modules/plugins_settings.tcl @ 1143

Revision 2, 2.5 KB checked in by jamesoff, 9 years ago (diff)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1## plugins settings engine for bMotion
2#
3# $Id: #
4#
5
6###############################################################################
7# bMotion - an 'AI' TCL script for eggdrops
8# Copyright (C) James Michael Seward 2000-2002
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23###############################################################################
24
25if {![info exists bMotion_plguins_settings]} {
26  set bMotion_plugins_settings(dummy,setting,channel,nick) "dummy"
27}
28
29proc bMotion_plugins_settings_set { plugin setting channel nick val } {
30  global bMotion_plugins_settings
31
32  if {$nick == ""} { set nick "_" }
33  if {$channel == ""} { set channel "_" }
34  if {$setting == ""} { 
35    bMotion_putloglev d * "bMotion: $plugin tried to save without giving a setting name"
36    return 0
37  }
38  if {$plugin == ""} { 
39    bMotion_putloglev d * "bMotion: Unknown plugin trying to save a setting"
40    return 0
41  }
42
43  if {$plugin == "dummy"} {
44    return ""
45  }
46
47  bMotion_putloglev 2 * "bMotion: Saving plugin setting $setting,$channel,$nick -> $val (from plugin $plugin)"
48  set bMotion_plugins_settings($plugin,$setting,$channel,$nick) $val
49  return 0
50}
51
52proc bMotion_plugins_settings_get { plugin setting channel nick } {
53  global bMotion_plugins_settings
54
55  if {$nick == ""} { set nick "_" }
56  if {$channel == ""} { set channel "_" }
57  if {$setting == ""} { 
58    bMotion_putloglev d * "bMotion: $plugin tried to get without giving a setting name"
59    return 0
60  }
61  if {$plugin == ""} { 
62    bMotion_putloglev d * "bMotion: Unknown plugin trying to get a setting"
63    return 0
64  }
65
66  if {$plugin == "dummy"} {
67    return ""
68  }
69
70  if [info exists bMotion_plugins_settings($plugin,$setting,$channel,$nick)] {
71    return $bMotion_plugins_settings($plugin,$setting,$channel,$nick)
72  }
73
74  bMotion_putloglev 1 * "bMotion: plugin $plugin tried to get non-existent value $setting,$channel,$nick"
75  return ""
76}
Note: See TracBrowser for help on using the repository browser.