当前位置: 首页>>代码示例>>Python>>正文


Python PushBullet.push_note方法代码示例

本文整理汇总了Python中pushbullet.PushBullet.push_note方法的典型用法代码示例。如果您正苦于以下问题:Python PushBullet.push_note方法的具体用法?Python PushBullet.push_note怎么用?Python PushBullet.push_note使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pushbullet.PushBullet的用法示例。


在下文中一共展示了PushBullet.push_note方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_push

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
    def send_push(title, body):
        pushbullet = PushBullet(api_key)
        if not devices:
            pushbullet.push_note(title=title, body=body)
        else:
            # load devices
            d = pushbullet.devices

            for i in devices:
                d[i].push_note(title=title, body=body)
开发者ID:Saturn,项目名称:live-football-ontv,代码行数:12,代码来源:run.py

示例2: PushBulletSender

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PushBulletSender(Sender):
    def __init__(self, setting):
        super(PushBulletSender, self).__init__(setting)

        self.pushbullet = PushBullet(self.config_api)
        if hasattr(self, 'config_channel'):
            self.pushbullet = self.pushbullet.get_channel(self.config_channel)

    def post(self, title, message, url):
        if url:
            message = '{}\n{}'.format(message, url)
        self.pushbullet.push_note(title, message)
开发者ID:d3m3vilurr,项目名称:ridinoti2pushbullet,代码行数:14,代码来源:pushbullet.py

示例3: push_note

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
    def push_note(self, event):
        """
        Pushes a note to the configured pushbullet accounts
        """

        host = event.host
        title = event.title + ": " + host
        message = host + ": " + event.message + " at " + \
                event.timestamp.strftime("%H:%M:%S %m/%d/%y")

        for key in self.api_keys:
            pb = PushBullet(key)
            pb.push_note(title, message)
开发者ID:thenaterhood,项目名称:heartbeat,代码行数:15,代码来源:pushbullet.py

示例4: PushBulletNotificationService

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PushBulletNotificationService(BaseNotificationService):
    """ Implements notification service for Pushbullet. """

    def __init__(self, api_key):
        from pushbullet import PushBullet

        self.pushbullet = PushBullet(api_key)

    def send_message(self, message="", **kwargs):
        """ Send a message to a user. """

        title = kwargs.get(ATTR_TITLE)

        self.pushbullet.push_note(title, message)
开发者ID:naixlesl,项目名称:home-assistant,代码行数:16,代码来源:pushbullet.py

示例5: __init__

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class Flow:
    def __init__(self, googleapi, api_key, email, **_):
        if api_key == 'YOUR_API_KEY_HERE':
            raise ValueError('Missing api key in settings')

        self.email = email
        self.pb = PushBullet(api_key)

        self.credentials_storage_path = googleapi.credentials_storage_path
        self.flow = flow_from_clientsecrets(
            filename=googleapi.client_secrets_path,
            scope='https://www.googleapis.com/auth/calendar.readonly',
            redirect_uri='urn:ietf:wg:oauth:2.0:oob')

        self.last_check = None
        self.callback = lambda: None

    def run(self, callback):
        self.callback = callback

        authorize_url = self.flow.step1_get_authorize_url()
        self.pb.push_link('Google Auth Request', authorize_url, email=self.email)
        self.last_check = datetime.now()

    def iter_received_codes(self):
        pushes = self.pb.get_pushes(modified_after=self.last_check.timestamp())
        self.last_check = datetime.now()
        for push in pushes:
            if push['type'] == 'note' and push['sender_email'] == self.email:
                self.pb.dismiss_push(push['iden'])
                yield push['body'].strip()

    def check_response(self):
        if self.last_check is None:
            return

        for code in self.iter_received_codes():
            try:
                credential = self.flow.step2_exchange(code)
                Storage(self.credentials_storage_path).put(credential)
                break
            except (ValueError, FlowExchangeError) as error:
                self.pb.push_note('', 'Error: ' + str(error), email=self.email)
        else:
            return

        self.last_check = None
        self.callback()
        self.pb.push_note('', 'Authentication complete', email=self.email)
开发者ID:skoslowski,项目名称:LANtopPy,代码行数:51,代码来源:authenticator.py

示例6: PushbulletLogHandler

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PushbulletLogHandler(logging.Handler):
    def __init__(self, api_key, stack_trace=False):
        logging.Handler.__init__(self)
        self.api_key = api_key
        self.stack_trace = stack_trace
        self.pb_session = PushBullet(self.api_key)

    def emit(self, record):
        message = '{}'.format(record.getMessage())

        if self.stack_trace and record.exc_info:
            message += '\n'
            message += '\n'.join(traceback.format_exception(*record.exc_info))

        self.pb_session.push_note('' + str(self.level), message)
开发者ID:mathiasose,项目名称:pushbullet_log_handler,代码行数:17,代码来源:__init__.py

示例7: PushbulletNotifier

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
    class PushbulletNotifier(AbstractNotifier):

        def __init__(self, api_key):
            self.pb = PushBullet(api_key)

        def notify(self, title, message):
            self.pb.push_note(title, message)

        @staticmethod
        def is_enabled():
            if Config.pushbullet_token:
                return True
            return False

        @classmethod
        def from_config(cls):
            return cls(Config.pushbullet_token)
开发者ID:buluba89,项目名称:Yatcobot,代码行数:19,代码来源:notifier.py

示例8: PB_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PB_Alarm(Alarm):
    def __init__(self, api_key):
        self.client = PushBullet(api_key)
        log.info("PB_Alarm intialized.")
        push = self.client.push_note("PokeAlarm activated!", "We will alert you about pokemon.")

    def pokemon_alert(self, pokemon):
        notification_text = "A wild " + pokemon['name'].title() + " has appeared!"
        google_maps_link = gmaps_link(pokemon["lat"], pokemon["lng"])
        time_text = pkmn_time_text(pokemon['disappear_time'])
        push = self.client.push_link(notification_text, google_maps_link, body=time_text)
开发者ID:ykurtbas,项目名称:PokemonGo-Map,代码行数:13,代码来源:pb_alarm.py

示例9: pushbullet_post

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
    def pushbullet_post(self, issue):
        """ Posts to Pushbullet API.
        For future reference, the push_note() function returns two
        values. One bool that specificies whether the push was a success
        or not, and a dict with additional info.
        """

        pb = PushBullet('YOUR-API-KEY')
        worked, push = pb.push_note(u"Förseningar", issue)
        if not worked:
            print(push)
开发者ID:johanberglind,项目名称:SLNotify,代码行数:13,代码来源:SLNotify.py

示例10: PushbulletClient

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PushbulletClient(PushNotificationClient):

    _client = None

    def get_name(self):
        return "Pushbullet"

    def set_api_key(self, api):
        try:
            self._client = PushBullet(api)
        except Exception as e:
            self._logger.exception(str(e))

    def send_message(self, title, msg):
        try:
            self._client.push_note(title=title, body=msg)
        except Exception as e:
            self._logger.exception(str(e))

    def set_logger(self, logger):
        pass
开发者ID:smartycoder,项目名称:DSVideoMonitor,代码行数:23,代码来源:PushbulletClient.py

示例11: push

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
 def push(self):
     """ Push a task """
     p = PushBullet(self.api)
     if self.type == 'text':
         success, push = p.push_note(self.title, self.message)
     elif self.type == 'list':
         self.message = self.message.split(',')
         success, push = p.push_list(self.title, self.message)
     elif self.type == 'link':
         success, push = p.push_link(self.title, self.message)
     else:
         success, push = p.push_file(file_url=self.message, file_name="cat.jpg", file_type="image/jpeg")
开发者ID:PhompAng,项目名称:To-do-Bullet,代码行数:14,代码来源:server.py

示例12: Pushbullet_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class Pushbullet_Alarm(Alarm):
	
	def __init__(self, settings):
		self.client = PushBullet(settings['api_key']) 
		log_msg = "Pushbullet Alarm intialized"
		if 'name' in settings:
			self.name = settings['name']
			log_mst = log_msg + ": " + self.name
		log.info(log_msg)
		push = self.client.push_note("PokeAlarm activated!", "We will alert you about pokemon.")
		
	def pokemon_alert(self, pkinfo):
		notification_text = pkinfo['alert']
		if hasattr(self, 'name') :
			notification_text = self.name + ": " + notification_text
		gmaps_link = pkinfo['gmaps_link']
		time_text =  pkinfo['time_text']
		push = self.client.push_link(notification_text, gmaps_link, body=time_text)
开发者ID:3eyedRaven,项目名称:PokeAlarm,代码行数:20,代码来源:pushbullet_alarm.py

示例13: PB_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
class PB_Alarm(Alarm):
	
	def __init__(self, api_key):
		self.client = PushBullet(api_key) 
		log.info("PB_Alarm intialized.")
		push = self.client.push_note("PokeAlarm activated!", "We will alert you about pokemon.")
		
	def pokemon_alert(self, pokemon):
		#notification_text = "A wild " + pokemon['name'].title() + " has appeared!"
		# Or retrieve a channel by its channel_tag. Note that an InvalidKeyError is raised if the channel_tag does not exist
		#your pushbullet channelname
		my_channel = self.client.get_channel('YOURCHANNELNAME') 
		
		google_maps_link = gmaps_link(pokemon["lat"], pokemon["lng"])
		time_text =  pkmn_time_text(pokemon['disappear_time'])
		notification_text = "("+ pokemon['name'].title() + " found" +"! "+" "  + time_text + "."
		push = self.client.push_link(notification_text, google_maps_link, body=time_text)
		#send to channel
		push = self.client.push_link(notification_text, google_maps_link, body=time_text, channel=my_channel)
开发者ID:malosaa,项目名称:PokemonGo-Finder_,代码行数:21,代码来源:pb_alarm.py

示例14: mention

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]

#.........这里部分代码省略.........
                """prevent most duplicate mentions (in the case of syncouts)"""
                logging.info(_("suppressing duplicate mention for {} ({})").format(event.user.full_name, event.user.id_.chat_id))
                continue

            if bot.memory.exists(["donotdisturb"]):
                if _user_has_dnd(bot, u.id_.chat_id):
                    logging.info(_("suppressing @mention for {} ({})").format(u.full_name, u.id_.chat_id))
                    user_tracking["ignored"].append(u.full_name)
                    continue

            if username_lower == nickname_lower:
                if u not in exact_nickname_matches:
                    exact_nickname_matches.append(u)

            if u not in mention_list:
                mention_list.append(u)

    """prioritise exact nickname matches"""
    if len(exact_nickname_matches) == 1:
        logging.info(_("prioritising nickname match for {}").format(exact_nickname_matches[0].full_name))
        mention_list = exact_nickname_matches

    if len(mention_list) > 1 and username_lower != "all":
        if conv_1on1_initiator:
            text_html = _('{} users would be mentioned with "@{}"! Be more specific. List of matching users:<br />').format(
                len(mention_list), username, conversation_name)

            for u in mention_list:
                text_html += u.full_name
                if bot.memory.exists(['user_data', u.id_.chat_id, "nickname"]):
                    text_html += ' (' + bot.memory.get_by_path(['user_data', u.id_.chat_id, "nickname"]) + ')'
                text_html += '<br />'

            bot.send_message_parsed(conv_1on1_initiator, text_html)

        logging.info(_("@{} not sent due to multiple recipients").format(username_lower))
        return #SHORT-CIRCUIT

    """send @mention alerts"""
    for u in mention_list:
            alert_via_1on1 = True

            """pushbullet integration"""
            if bot.memory.exists(['user_data', u.id_.chat_id, "pushbullet"]):
                pushbullet_config = bot.memory.get_by_path(['user_data', u.id_.chat_id, "pushbullet"])
                if pushbullet_config is not None:
                    if pushbullet_config["api"] is not None:
                        pb = PushBullet(pushbullet_config["api"])
                        success, push = pb.push_note(
                            _("{} mentioned you in {}").format(
                                    event.user.full_name,
                                    conversation_name),
                                event.text)
                        if success:
                            user_tracking["mentioned"].append(u.full_name)
                            logging.info(_("{} ({}) alerted via pushbullet").format(u.full_name, u.id_.chat_id))
                            alert_via_1on1 = False # disable 1on1 alert
                        else:
                            user_tracking["failed"]["pushbullet"].append(u.full_name)
                            logging.warning(_("pushbullet alert failed for {} ({})").format(u.full_name, u.id_.chat_id))

            if alert_via_1on1:
                """send alert with 1on1 conversation"""
                conv_1on1 = bot.get_1on1_conversation(u.id_.chat_id)
                if conv_1on1:
                    bot.send_message_parsed(
                        conv_1on1,
                        _("<b>{}</b> @mentioned you in <i>{}</i>:<br />{}").format(
                            event.user.full_name,
                            conversation_name,
                            event.text)) # prevent internal parser from removing <tags>
                    mention_chat_ids.append(u.id_.chat_id)
                    user_tracking["mentioned"].append(u.full_name)
                    logging.info(_("{} ({}) alerted via 1on1 ({})").format(u.full_name, u.id_.chat_id, conv_1on1.id_))
                else:
                    user_tracking["failed"]["one2one"].append(u.full_name)
                    if bot.get_config_suboption(event.conv_id, 'mentionerrors'):
                        bot.send_message_parsed(
                            event.conv,
                            _("@mention didn't work for <b>{}</b>. User must say something to me first.").format(
                                u.full_name))
                    logging.warning(_("user {} ({}) could not be alerted via 1on1").format(u.full_name, u.id_.chat_id))

    if noisy_mention_test:
        text_html = _("<b>@mentions:</b><br />")
        if len(user_tracking["failed"]["one2one"]) > 0:
            text_html = text_html + _("1-to-1 fail: <i>{}</i><br />").format(", ".join(user_tracking["failed"]["one2one"]))
        if len(user_tracking["failed"]["pushbullet"]) > 0:
            text_html = text_html + _("PushBullet fail: <i>{}</i><br />").format(", ".join(user_tracking["failed"]["pushbullet"]))
        if len(user_tracking["ignored"]) > 0:
            text_html = text_html + _("Ignored (DND): <i>{}</i><br />").format(", ".join(user_tracking["ignored"]))
        if len(user_tracking["mentioned"]) > 0:
            text_html = text_html + _("Alerted: <i>{}</i><br />").format(", ".join(user_tracking["mentioned"]))
        else:
            text_html = text_html + _("Nobody was successfully @mentioned ;-(<br />")

        if len(user_tracking["failed"]["one2one"]) > 0:
            text_html = text_html + _("Users failing 1-to-1 need to say something to me privately first.<br />")

        bot.send_message_parsed(event.conv, text_html)
开发者ID:CyBot,项目名称:hangupsbot,代码行数:104,代码来源:mentions.py

示例15: print

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_note [as 别名]
            try:
                if settings.pushbullet_use_channel:
                    channels = p.channels
                    for channel in channels:
                        #print dev.device_iden + ' ' + dev.nickname
                        if channel.channel_tag == settings.pushbullet_channel_tag:
                            sendto_channel = channel
                    if not sendto_channel:
                        logger.error('PushBullet channel configured, but tag "' + settings.pushbullet_channel_tag + '" not found')
                        print('PushBullet channel configured, but tag "' + settings.pushbullet_channel_tag + '" not found')
            except AttributeError, e:
                logger.error('PushBullet channel settings not found - ' + str(e))
                print('PushBullet channel settings not found, see settings_example.py - ' + str(e))

            for disruption in changed_disruptions:
                message = format_disruption(disruption)
                logger.debug(message)
                #print message
                if sendto_channel:
                    sendto_channel.push_note(message['header'], message['message'])
                else:
                    p.push_note(message['header'], message['message'], sendto_device)
        if trips:
            for trip in trips:
                if trip.has_delay:
                    message = format_trip(trip)
                    #print message
                    logger.debug(message)
                    #p.push_note('title', 'body', sendto_device)
                    p.push_note(message['header'], message['message'], sendto_device)
开发者ID:simonfiddaman,项目名称:ns-notifications,代码行数:32,代码来源:ns_notifications.py


注:本文中的pushbullet.PushBullet.push_note方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。