2 # UserInfo.pl: User Information Services
4 # Version: v0.1 (20000509).
6 # NOTE: Idea from Flugh. Originally written in tcl for eggdrop by
12 my $orderOfInfo = "RN,J,C,W,D";
25 foreach (split /\|/, $text) {
26 if (/^\s*(\S+):\s*(.*)\s*$/) {
38 foreach (sort keys %hash) {
39 push(@array, "$_: $hash{$_}");
51 $query =~ s/^\s+|\s+$//g if (defined $query);
53 if (!defined $query or $query =~ /^$/) {
58 if ($query !~ /^$mask{nick}$/) {
59 &msg($who, "Invalid query of '$query'.");
64 if ($result = &getFactoid($query." info")) {
67 &performReply("No User Information on \002$query\002");
71 if ($result !~ /\|/) {
72 &msg($who, "Invalid User Information for '$query'.");
76 my %userInfo = &UserInfo2Hash($result);
79 foreach (split ',', $orderOfInfo) {
80 next unless (exists $userInfo{$_});
81 push(@reply, "$infoDesc{$_}: $userInfo{$_}");
84 &performStrictReply("User Information on $userInfo{'N'} -- ".
89 my($type, $what) = @_;
93 if (&IsLocked("$who info")) {
94 &DEBUG("UIS: IsLocked('$who info') == 1.");
99 if (my $result = &getFactoid("$who info")) {
100 %userInfo = &UserInfo2Hash($result);
102 &DEBUG("UIS: new = 1!");
103 $userInfo{'N'} = $who;
107 ### TODO: hash for %infoS2L.
108 if ($type =~ /^(RN|real\s*name)$/i) {
110 } elsif ($type =~ /^(J|job|occupation|school|life)$/i) {
112 } elsif ($type =~ /^(C|contact|email|phone)$/i) {
114 } elsif ($type =~ /^(W|www|url|web\s*page|home\s*page)$/i) {
116 } elsif ($type =~ /^(D|desc\S+)$/i) {
118 } elsif ($type =~ /^(O|opt\S+)$/i) {
121 &msg($who, "Unknown type '$type'.");
125 if (!defined $what) { # !defined.
126 if (exists $userInfo{$info}) {
127 &msg($who, "Current \002$infoDesc{$info}\002 is: '$userInfo{$info}'.");
129 &msg($who, "No current \002$infoDesc{$info}\002.");
133 foreach (split ',', $orderOfInfo) {
134 next if (exists $userInfo{$_});
135 push(@remain, $infoDesc{$_});
137 if (scalar @remain) {
138 ### TODO: show short-cut (identifier) aswell.
139 &msg($who, "Remaining slots to fill: ".join(' ', @remain));
141 ### &msg($who, "Personal Information completely filled. Good.");
145 } elsif ($what =~ /^$/) { # defined but NULL. UNSET
146 if (exists $userInfo{$info}) {
147 &msg($who, "Unsetting \002$infoDesc{$info}\002 ($userInfo{$info}).");
148 delete $userInfo{$info};
150 &msg($who, "\002$infoDesc{$info}\002 is already empty!");
154 if (exists $userInfo{$info}) {
155 &msg($who, "\002$infoDesc{$info}\002 was '$userInfo{$info}'.");
156 &msg($who, "Now is: '$what'.");
158 &msg($who, "\002$infoDesc{$info}\002 is now '$what'.");
160 $userInfo{$info} = $what;
163 &setFactInfo($who." info", "factoid_value", &Hash2UserInfo(%userInfo));
165 &DEBUG("UIS: locking '$who info'.");
166 &DEBUG("UIS: nuh => '$nuh'.");
167 &setFactInfo("$who info", "locked_by", $nuh);
168 &setFactInfo("$who info", "locked_time", time());