Software Freedom Law Center

root/trunk/antimatter/tim/Scripts/add-user.plx

Revision 53, 2.2 kB (checked in by bkuhn, 9 months ago)
  • Added SFLC's internally developed tim bot released under AGPLv3
Line 
1 # Copyright (C) 2005, 2006, 2007, 2008   Software Freedom Law Center, Inc.
2 #  Author: Bradley M. Kuhn <bkuhn@softwarefreedom.org>
3 #
4 #  This software gives you freedom; it is licensed to you under version
5 #  3 of the GNU Affero General Public License.
6 #
7 #  This software is distributed WITHOUT ANY WARRANTY, without even the
8 #  implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR
9 #  PURPOSE.  See the GNU Affero General Public License for further
10 #  details.
11 #
12 # You should have received a copy of the GNU Affero General Public
13 # License, version 3 along with this software.  If not, see
14 # <http://www.gnu.org/licenses/>.
15 #!/usr/bin/perl -I ../Modules
16 use strict;
17 use warnings;
18
19 use SFLC::TimeTracker::DB;
20 use Data::Dumper;
21 my $database = new SFLC::TimeTracker::DB("MLDBM", "time-data.mldbm",
22                                        "pending-time.mldbm");
23
24 die "no user" unless defined $ARGV[0];
25
26 my $u = $ARGV[0];
27
28 $database->beginWriteWork("pending");
29 $database->beginWriteWork("main");
30
31 my %cats = %{$database->{main}{categoryAliases}};
32 $cats{users}{$u} = {};
33
34 $database->{main}{categoryAliases} = \%cats;
35
36 my %me = %{$database->{main}{entries}};
37
38 $me{byUser}{$u} = {};
39 $database->{main}{entries} = \%me;
40
41 my %pe = %{$database->{pending}{entries}};
42
43 $pe{byUser}{$u} = {};
44 $database->{pending}{entries} = \%pe;
45
46 my %pc = %{$database->{pending}{configs}};
47
48 $pc{users}{$u} = { stack => [] };
49
50 $database->{pending}{configs} = \%pc;
51
52 my %il = %{$database->{main}{ignoreLines}};
53
54 $il{users}{$u} = { };
55
56 $database->{pending}{ignoreLines} = \%il;
57
58 my %itr = %{$database->{pending}{interactionTrees}};
59
60 $itr{$u} = [];
61 $database->{pending}{interactionTrees} = \%itr;
62
63 my %mc = %{$database->{main}{configs}};
64
65 delete $mc{$u} if exists $mc{$u};
66
67 $mc{users}{$u} = {};
68
69 $database->{main}{configs} = \%mc;
70
71 my(%x) = %{$database->{main}{userConfig}};
72 $x{$u} = {};
73 $database->{main}{userConfig} = \%x;
74
75 foreach my $config (qw/categoryParser speakWhenSpokenTo alwaysAnswerPrivate/) {
76   if ($config eq "categoryParser") {
77     $database->setUserConfigValue($u, $config, "BasicLawyer");
78   } else {
79     $database->setUserConfigValue($u, $config, 0);
80   }
81 }
82
83 $database->endWriteWork("pending");
84 $database->endReadWork("main");
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC