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' ) ) {
69 &performReply("No User Information on \002$query\002");
73 if ( $result !~ /\|/ ) {
74 &msg( $who, "Invalid User Information for '$query'." );
78 my %userInfo = &UserInfo2Hash($result);
81 foreach ( split ',', $orderOfInfo ) {
82 next unless ( exists $userInfo{$_} );
83 push( @reply, "$infoDesc{$_}: $userInfo{$_}" );
87 "User Information on $userInfo{'N'} -- " . join( ', ', @reply ) );
91 my ( $type, $what ) = @_;
95 if ( &IsLocked("$who info") ) {
96 &DEBUG("UIS: IsLocked('$who info') == 1.");
101 if ( my $result = &getFactoid("$who info") ) {
102 %userInfo = &UserInfo2Hash($result);
105 &DEBUG("UIS: new = 1!");
106 $userInfo{'N'} = $who;
110 ### TODO: hash for %infoS2L.
111 if ( $type =~ /^(RN|real\s*name)$/i ) {
114 elsif ( $type =~ /^(J|job|occupation|school|life)$/i ) {
117 elsif ( $type =~ /^(C|contact|email|phone)$/i ) {
120 elsif ( $type =~ /^(W|www|url|web\s*page|home\s*page)$/i ) {
123 elsif ( $type =~ /^(D|desc\S+)$/i ) {
126 elsif ( $type =~ /^(O|opt\S+)$/i ) {
130 &msg( $who, "Unknown type '$type'." );
134 if ( !defined $what ) { # !defined.
135 if ( exists $userInfo{$info} ) {
137 "Current \002$infoDesc{$info}\002 is: '$userInfo{$info}'." );
140 &msg( $who, "No current \002$infoDesc{$info}\002." );
144 foreach ( split ',', $orderOfInfo ) {
145 next if ( exists $userInfo{$_} );
146 push( @remain, $infoDesc{$_} );
148 if ( scalar @remain ) {
149 ### TODO: show short-cut (identifier) aswell.
150 &msg( $who, "Remaining slots to fill: " . join( ' ', @remain ) );
153 ### &msg($who, "Personal Information completely filled. Good.");
158 elsif ( $what =~ /^$/ ) { # defined but NULL. UNSET
159 if ( exists $userInfo{$info} ) {
161 "Unsetting \002$infoDesc{$info}\002 ($userInfo{$info})." );
162 delete $userInfo{$info};
165 &msg( $who, "\002$infoDesc{$info}\002 is already empty!" );
170 if ( exists $userInfo{$info} ) {
171 &msg( $who, "\002$infoDesc{$info}\002 was '$userInfo{$info}'." );
172 &msg( $who, "Now is: '$what'." );
175 &msg( $who, "\002$infoDesc{$info}\002 is now '$what'." );
177 $userInfo{$info} = $what;
180 &setFactInfo( $who . ' info', 'factoid_value', &Hash2UserInfo(%userInfo) );
182 &DEBUG("UIS: locking '$who info'.");
183 &DEBUG("UIS: nuh => '$nuh'.");
184 &setFactInfo( "$who info", "locked_by", $nuh );
185 &setFactInfo( "$who info", "locked_time", time() );
191 # vim:ts=4:sw=4:expandtab:tw=80