本文整理汇总了Python中pushbullet.PushBullet.get_channel方法的典型用法代码示例。如果您正苦于以下问题:Python PushBullet.get_channel方法的具体用法?Python PushBullet.get_channel怎么用?Python PushBullet.get_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pushbullet.PushBullet
的用法示例。
在下文中一共展示了PushBullet.get_channel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PushBulletSender
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import get_channel [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)
示例2: PB_Alarm
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import get_channel [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)