If the Badge class defines a message, send it to the user who was just
        awarded the badge.
509841
def send_badge_messages(self, badge_award):
        
        user_message = getattr(badge_award.badge, "user_message", None)
        if callable(user_message):
            message = user_message(badge_award)
        else:
            message = user_message
        if message is not None:
            badge_award.user.message_set.create(message=message)
151544
function onMessage(userId, msg) {
    var dialogId = msg.dialog_id,
        isForCurrentDialog = isMessageForCurrentDialog(userId, dialogId);

    updateCallState({
        dialogId: dialogId,
        userId: userId,
        active: isForCurrentDialog,
        type: msg.extension.notification_type
    });

    if (!msg.body) return true;

    // check if it's a message for current dialog
    if (isMessageForCurrentDialog(userId, dialogId)) {
        dialogsMessages.push(msg);

        if (msg.markable === 1 && userId != currentUser.id) {
            sendReadStatus(userId, msg.id, dialogId);
        }

        // сheck if it's an attachment
        //
        var messageAttachmentFileId = null;

        if (msg.extension.hasOwnProperty("attachments")) {
            if (msg.extension.attachments.length > 0) {
                messageAttachmentFileId = msg.extension.attachments[0].id;
            }
        }

        showMessage(userId, msg, messageAttachmentFileId);
    }

    // Here we process the regular messages
    //
    updateDialogsList(dialogId, msg.body);

    if (userId != currentUser.id) {
        playSoundOnNewMessage();
    }
}
618013
def send_reminder(self, user, sender=None, **kwargs):
        """"""
        if user.is_active:
            return False
        token = RegistrationTokenGenerator().make_token(user)
        kwargs.update({"token": token})
        self.email_message(
            user, self.reminder_subject, self.reminder_body, sender, **kwargs
        ).send()
258299
def send_message(self, message, icon_path=None):
        """"""
        icon_encoded_string = ''
        icon_extension = ''

        if icon_path is not None:
            icon_extension = os.path.splitext(icon_path)[1][1:]
            with open(icon_path, 'rb') as icon_file:
                icon_encoded_string = base64.b64encode(icon_file.read()).decode('ascii')

        self.request(EP_SHOW_MESSAGE, {
            'message': message,
            'iconData': icon_encoded_string,
            'iconExtension': icon_extension
        })
1209990
def notify_user(self, msg, level="info", rate_limit=5, title=None, icon=None):
        
        module_name = self._module.module_full_name
        if isinstance(msg, Composite):
            msg = msg.text()
        if title is None:
            title = "py3status: {}".format(module_name)
        elif isinstance(title, Composite):
            title = title.text()
        # force unicode for python2 str
        if self._is_python_2:
            if isinstance(msg, str):
                msg = msg.decode("utf-8")
            if isinstance(title, str):
                title = title.decode("utf-8")
        if msg:
            self._py3_wrapper.notify_user(
                msg=msg,
                level=level,
                rate_limit=rate_limit,
                module_name=module_name,
                title=title,
                icon=icon,
            )
919947
def announce(self, msg):
        
        self.print_if_verbose("{} -> {}".format(self.network_uid, msg.__class__.__name__))
        self.__trigger_event__(
            event_class=self.MessageAnnounced,
            msg=msg,
        )
629342
def sendMessage(self, message, thread_id=None, thread_type=ThreadType.USER):
        
        return self.send(
            Message(text=message), thread_id=thread_id, thread_type=thread_type
        )
997072
def send_notification(method, params)
      data = MessagePack.dump([2, method, params]).bytes
      ws.send(data)
    rescue => exc
      warn exc
      abort exc
    end
140383
def reviewed_badge(user, talk):
    """"""
    context = {
        'reviewed': False,
    }

    review = None
    if user and not user.is_anonymous():
        review = talk.reviews.filter(reviewer=user).first()

    if review:
        context['reviewed'] = True
        context['review_is_current'] = review.is_current()

    return context
370351
def acknowledge_message(self, delivery_tag):
        
        _logger.debug('Acknowledging message %s', delivery_tag)
        self._channel.basic_ack(delivery_tag)
1256853
def notify_handler(verb, **kwargs):
    

    # Pull the options out of kwargs
    kwargs.pop('signal', None)
    recipient = kwargs.pop('recipient')
    actor = kwargs.pop('sender')
    optional_objs = [
        (kwargs.pop(opt, None), opt)
        for opt in ('target', 'action_object')
    ]
    public = bool(kwargs.pop('public', True))
    description = kwargs.pop('description', None)
    timestamp = kwargs.pop('timestamp', timezone.now())
    level = kwargs.pop('level', Notification.LEVELS.info)

    # Check if User or Group
    if isinstance(recipient, Group):
        recipients = recipient.user_set.all()
    elif isinstance(recipient, (QuerySet, list)):
        recipients = recipient
    else:
        recipients = [recipient]

    new_notifications = []

    for recipient in recipients:
        newnotify = Notification(
            recipient=recipient,
            actor_content_type=ContentType.objects.get_for_model(actor),
            actor_object_id=actor.pk,
            verb=text_type(verb),
            public=public,
            description=description,
            timestamp=timestamp,
            level=level,
        )

        # Set optional objects
        for obj, opt in optional_objs:
            if obj is not None:
                setattr(newnotify, '%s_object_id' % opt, obj.pk)
                setattr(newnotify, '%s_content_type' % opt,
                        ContentType.objects.get_for_model(obj))

        if kwargs and EXTRA_DATA:
            newnotify.data = kwargs

        newnotify.save()
        new_notifications.append(newnotify)

    return new_notifications
762588
def badge_label(self, badge):
        ''''''
        kind = badge.kind if isinstance(badge, Badge) else badge
        return self.__badges__[kind]
13239
function sendBadge(format, badgeData) {
          if (serverUnresponsive) {
            return
          }
          clearTimeout(serverResponsive)
          // Check for a change in the data.
          let dataHasChanged = false
          if (
            cached !== undefined &&
            cached.data.badgeData.text[1] !== badgeData.text[1]
          ) {
            dataHasChanged = true
          }
          // Add format to badge data.
          badgeData.format = format
          // Update information in the cache.
          const updatedCache = {
            reqs: cached ? cached.reqs + 1 : 1,
            dataChange: cached
              ? cached.dataChange + (dataHasChanged ? 1 : 0)
              : 1,
            time: +reqTime,
            interval: cacheInterval,
            data: { format, badgeData },
          }
          requestCache.set(cacheIndex, updatedCache)
          if (!cachedVersionSent) {
            const svg = makeBadge(badgeData)
            setCacheHeadersOnResponse(ask.res, badgeData.cacheLengthSeconds)
            makeSend(format, ask.res, end)(svg)
          }
        }
212259
async def on_message(message):
    

    # Simplify message info
    server = message.server
    author = message.author
    channel = message.channel
    content = message.content

    data = datatools.get_data()

    if not data["discord"]["servers"][server.id][_data.modulename]["activated"]:
        return

    # Only reply to server messages and don't reply to myself
    if server is not None and author != channel.server.me:
        # Commands section
        prefix = data["discord"]["servers"][server.id]["prefix"]
        if content.startswith(prefix):
            # Parse message
            package = content.split(" ")
            command = package[0][len(prefix):]

            # Commands
            if command == 'gamedeals':
                await client.send_typing(channel)

                # Get posts from Reddit API
                posts = api_reddit.get_top10()

                if posts:
                    for post in posts:
                        # Create embed UI
                        embed = ui_embed.success(channel, post)
                        await embed.send()
                else:
                    embed = ui_embed.no_results(channel)
                    await embed.send()
338416
private function sendTERMSignal()
    {
        if (!$this->hasReceivedHUP) {
            $this->hasReceivedHUP = true;
            try {
                $this->process->signal(SIGTERM);
            } catch (\Symfony\Component\Process\Exception\LogicException $e) {
                //In case the process ends between checking and actually sending the signal
            }
        }
    }
244128
def _Notify(username, notification_type, message, object_reference):
  """"""

  # Do not try to notify system users (e.g. Cron).
  if username in aff4_users.GRRUser.SYSTEM_USERS:
    return

  if object_reference:
    uc = object_reference.UnionCast()
    if hasattr(uc, "client_id"):
      message = _HostPrefix(uc.client_id) + message

  n = rdf_objects.UserNotification(
      username=username,
      notification_type=notification_type,
      state=rdf_objects.UserNotification.State.STATE_PENDING,
      message=message,
      reference=object_reference)
  data_store.REL_DB.WriteUserNotification(n)
467392
def set_message(self, title, msg, typ, url=None):
        
        return self.user.send_notification(title=title,
                                           message=msg,
                                           typ=typ,
                                           url=url)