source: trunk/modules/plugins_settings.tcl @ 1143

Revision 1111, 2.8 KB checked in by znx, 12 months ago (diff)

Patch by HellSpawn?, various fixes to spelling, brackets, function calls, et al

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