def pco_address_lookup(self, message, pco_name): """!address | "address for" (name): tells you the street address of a certain user""" if authenticate.check_name(message): if authenticate.get(message, app): self.reply("I might have that address.") attachment = [] for x in address.get(pco_name): attachment += x.slack() if not attachment: attachment = msg_attachment.SlackAttachment( text="Sorry I don't have a address for " + pco_name, pco="people", button_text="Search People", button_url="https://people.planningcenteronline.com/" "people?q=" + pco_name.replace(" ", "%20")) print(attachment.slack()) self.say("", message=message, attachments=attachment.slack(), channel=wl_chan_id(self)) else: self.say("Here you go!", message=message, attachments=attachment, channel=wl_chan_id(self)) else: self.say( "Sorry but you don't have access to the People App. " "Please contact your administrator.", channel=wl_chan_id(self)) else: self.say( 'I could not authenticate you. Please make sure your "Full name" ' 'is in your Slack profile and matches your Planning Center Profile.', channel=wl_chan_id(self))
def pco_giving_report(self, message, pco_date): """!giving | "giving since" (date): gives you a breakdown of giving since the date you specify.""" if authenticate.check_name(message): if authenticate.get(message, app): self.reply("Doing the math. This could take a few minutes.") attachment = [] for x in giving_report.get_giving(pco_date): attachment += x.slack() if not attachment: attachment = msg_attachment.\ SlackAttachment(text="Sorry something went wrong.", button_text="Search People", button_url="https://giving.planningcenteronline.com/" "donations?period=last_7_days") print(attachment.slack()) self.say("", message=message, attachments=attachment.slack()) else: self.say("Here you go!", message=message, attachments=attachment, channel=wl_chan_id(self)) else: self.say( "Sorry but you don't have access to the Giving App. " "Please contact your administrator.", channel=wl_chan_id(self)) else: self.say( 'I could not authenticate you. Please make sure your "Full name" ' 'is in your Slack profile and matches your Planning Center Profile.', channel=wl_chan_id(self))
def pco_checkin_lookup(self, message, pco_name): """!checkin [name]: tells you the last time someone checked-in""" if authenticate.check_name(message): if authenticate.get(message, app): print("checkin request") self.reply("Let me check.") attachment = [] attachment_txt = "" for x in checkins.get(pco_name): attachment += x.slack() attachment_txt += x.txt() if not attachment: attachment = msg_attachment.SlackAttachment(text="Sorry I don't have a Check-in for " + pco_name, pco="check_ins", button_text="Search Check-ins", button_url="https://check-ins." "planningcenteronline.com/people?q=" + pco_name.replace(" ", "%20")) self.say("", message=message, attachments=attachment.slack(), channel=wl_chan_id(self)) else: self.say("Here you go!", message=message, attachments=attachment, channel=wl_chan_id(self)) else: self.say("Sorry but you don't have access to the Check-ins App. " "Please contact your administrator.", channel=wl_chan_id(self)) else: self.say('I could not authenticate you. Please make sure your "Full name ' 'is in your Slack profile and matches your Planning Center Profile.', channel=wl_chan_id(self))
def pco_team_lookup(self, message, pco_team): """!team <team name>: returns a list of people serving on the team""" pco_team = pco_team.strip() if not pco_team: self.reply("Hold on I'll look up the teams for you.") else: self.reply("Hold on I'll look up that team for you.") team_list = teams.get(pco_team) attachment = [] for result in team_list: attachment += result.slack() if not attachment: self.say('Sorry I don\'t find a team named "' + pco_team + '" in services.', channel=wl_chan_id(self)) else: self.say("", message=message, attachments=attachment, channel=wl_chan_id(self))
def pco_team_lookup(self, message, pco_team): pco_team = pco_team.strip() """Lookup a [team] and print it's members""" if not pco_team: self.reply("Hold on I'll look up the teams for you.") else: self.reply("Hold on I'll look up that team for you.") team_list = teams.get(pco_team) attachment = [] for result in team_list: attachment += result.slack() if not attachment: self.say('Sorry I don\'t find a team named "' + pco_team + '" in services.', channel=wl_chan_id(self)) else: self.say("", message=message, attachments=attachment, channel=wl_chan_id(self))
def pco_team_schedule_lookup(self, message, pco_team, pco_date): """ "who is serving|scheduled on the <team name> team <date>": looks up a [team name] and displays its confirmed and unconfirmed members for a given date""" pco_team = pco_team.strip() self.reply("Hold on; I'll look up that team's schedule for you.") if pco_date.strip() == '': pco_date = 'today' attachments = teams.get_for_date(pco_team, pco_date) attachment = [] for returned_attachment in attachments: attachment += returned_attachment.slack() self.say("", message=message, attachments=attachment, channel=wl_chan_id(self))
def pco_forms(self, message): """!forms: lists the forms available on people and provides a button to open it.""" if authenticate.check_name(message): if authenticate.get(message, app): self.reply("Looking up forms. . .") logging.info("looking up forms") attachment = [] for x in forms.get_forms(): logging.info(x.slack()) attachment += x.slack() if not attachment: attachment = msg_attachment.SlackAttachment( text="Sorry I couldn't find any forms", button_text="Search People", button_url="https://people.planningcenteronline.com/" "people/forms") print(attachment.slack()) self.say("", message=message, attachments=attachment.slack(), channel=wl_chan_id(self)) else: self.say("Here you go!", message=message, attachments=attachment, channel=wl_chan_id(self)) else: self.say( "Sorry but you don't have access to the People App. " "Please contact your administrator.", channel=wl_chan_id(self)) else: self.say( 'I could not authenticate you. Please make sure your "Full name" ' 'is in your Slack profile and matches your Planning Center Profile.', channel=wl_chan_id(self))
def whitelist_channel(self, message): # NOTE You need to use self.say for this to work! self.say( "This response goes to the channel if it is a whitelisted channel, " "but goes to a DM if the channel isn't whitelisted.", channel=wl_chan_id(self))