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


Python PushBullet.push_link方法代码示例

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


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

示例1: send_notification

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [as 别名]
def send_notification(api_key, page_title, site_url):

    print "Sending PushBullet notification"

    pb_client = PushBullet(api_key)

    pb_client.push_link("Update on {title}!".format(title=page_title), site_url)
开发者ID:MarcDufresne,项目名称:pushbullet-crawler,代码行数:9,代码来源:scrapper.py

示例2: __init__

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [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

示例3: PB_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [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

示例4: PB_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [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

示例5: push

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [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

示例6: Pushbullet_Alarm

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [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

示例7: mention

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

#.........这里部分代码省略.........
            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 />'

                text_html += "<br /><em>To toggle this message on/off, use <b>/bot bemorespecific</b></em>"

                yield from bot.coro_send_message(conv_1on1_initiator, text_html)

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

    """support for reprocessor
    override the source name by defining event._external_source"""
    source_name = event.user.full_name
    if hasattr(event, '_external_source'):
        source_name = event._external_source

    """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:
                        success = False
                        try:
                            pb = PushBullet(pushbullet_config["api"])
                            push = pb.push_link(
                                title = _("{} mentioned you in {}").format(source_name, conversation_name),
                                    body=event.text,
                                    url='https://hangouts.google.com/chat/{}'.format(event.conv.id_) )
                            if isinstance(push, tuple):
                                # backward-compatibility for pushbullet library < 0.8.0
                                success = push[0]
                            elif isinstance(push, dict):
                                success = True
                            else:
                                raise TypeError("unknown return from pushbullet library: {}".format(push))
                        except Exception as e:
                            logger.exception("pushbullet error")

                        if success:
                            user_tracking["mentioned"].append(u.full_name)
                            logger.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)
                            logger.warning("pushbullet alert failed for {} ({})".format(u.full_name, u.id_.chat_id))

            if alert_via_1on1:
                """send alert with 1on1 conversation"""
                conv_1on1 = yield from bot.get_1to1(u.id_.chat_id, context={ 'initiator_convid': event.conv_id })
                if username_lower == "all":
                    message_mentioned = _("<b>{}</b> @mentioned ALL in <i>{}</i>:<br />{}")
                else:
                    message_mentioned = _("<b>{}</b> @mentioned you in <i>{}</i>:<br />{}")
                if conv_1on1:
                    yield from bot.coro_send_message(
                        conv_1on1,
                        message_mentioned.format(
                            source_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)
                    logger.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'):
                        yield from bot.coro_send_message(
                            event.conv,
                            _("@mention didn't work for <b>{}</b>. User must say something to me first.").format(
                                u.full_name))
                    logger.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 />")

        yield from bot.coro_send_message(event.conv, text_html)
开发者ID:PrinterElf,项目名称:hangoutsbot,代码行数:104,代码来源:mentions.py

示例8: push_link

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [as 别名]
def push_link(entries_list):
  print apiKey
  client = PushBullet(apiKey)
  for entry in entries_list:
    client.push_link(entry["title"], entry["link"])
开发者ID:ndminh92,项目名称:rsspushbullet,代码行数:7,代码来源:parse_feeds.py

示例9: send_alert_pushbullet

# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_link [as 别名]
def send_alert_pushbullet(alert, email):
    pb = PushBullet(settings.PUSHBULLET_ACCESS_TOKEN)
    title = 'new alert: %s' % (alert.title, )
    pb.push_link(title, 'http://127.0.0.1:8000/', body=alert.get_body(), email=email)
开发者ID:simpleoncall,项目名称:simpleoncall,代码行数:6,代码来源:push.py


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