Пример #1
0
        bool onRequest(VPServices app, Avatar source, string targetName, bool invite)
        {
            // Ignore if self
            if (source.Name.IEquals(targetName))
            {
                app.Warn(source.Session, msgSelf);
                return(true);
            }

            // Reject if source has request
            if (!isRequestee(source.Session).Equals(JoinInvite.Nobody))
            {
                app.Warn(source.Session, msgPendingRequester);
                return(Log.Info(Name, "Rejecting request by {0} as they already have one pending", source));
            }

            // Reject if target has request
            if (!isRequested(targetName).Equals(JoinInvite.Nobody))
            {
                app.Warn(source.Session, msgPendingRequestee);
                return(Log.Info(Name, "Rejecting request by {0} as they already have one pending", source));
            }

            // Ignore if no such users found
            var action  = invite ? "invite" : "join";
            var targets = app.GetUsers(targetName);

            if (targets.Length <= 0)
            {
                app.Warn(source.Session, msgNotPresent);
                return(true);
            }

            // Request all sessions of given name
            foreach (var target in targets)
            {
                app.Notify(target.Session, msgRequest, source.Name, action);
            }

            app.Notify(source.Session, msgRequestSent, targetName);
            requests.Add(new JoinInvite
            {
                By     = source.Session,
                Who    = targetName.ToLower(),
                When   = DateTime.Now,
                Invite = invite
            });

            return(true);
        }
Пример #2
0
        bool onRequest(VPServices app, Avatar source, string targetName, bool invite)
        {
            // Ignore if self
            if ( source.Name.IEquals(targetName) )
            {
                app.Warn(source.Session, msgSelf);
                return true;
            }

            // Reject if source has request
            if ( !isRequestee(source.Session).Equals(JoinInvite.Nobody) )
            {
                app.Warn(source.Session, msgPendingRequester);
                return Log.Info(Name, "Rejecting request by {0} as they already have one pending", source);
            }

            // Reject if target has request
            if ( !isRequested(targetName).Equals(JoinInvite.Nobody) )
            {
                app.Warn(source.Session, msgPendingRequestee);
                return Log.Info(Name, "Rejecting request by {0} as they already have one pending", source);
            }

            // Ignore if no such users found
            var action  = invite ? "invite" : "join";
            var targets = app.GetUsers(targetName);
            if ( targets.Length <= 0 )
            {
                app.Warn(source.Session, msgNotPresent);
                return true;
            }

            // Request all sessions of given name
            foreach (var target in targets)
                app.Notify(target.Session, msgRequest, source.Name, action);

            app.Notify(source.Session, msgRequestSent, targetName);
            requests.Add(new JoinInvite
            {
                By     = source.Session,
                Who    = targetName.ToLower(),
                When   = DateTime.Now,
                Invite = invite
            });

            return true;
        }