Ejemplo n.º 1
0
 def app_lookup(self, message, app):
     """!app: tells you which PCO apps you have permissions to"""
     print("This is what's in app: " + app)
     app = app.strip()
     if authenticate.check_name(message):
         if app:
             print("checking credentials")
             if authenticate.get(message, app):
                 msg = "You have access to: " + app.title()
                 attachment = msg_attachment.SlackAttachment(fallback=msg,
                                                             pco=app,
                                                             text=msg)
                 self.reply("",
                            message=message,
                            attachments=attachment.slack())
             else:
                 self.reply(
                     "Sorry but you don't have access to that Planning Center App. "
                     "Please contact your administrator.")
         else:
             self.reply("Getting your permissions. . .", message=message)
             print("calling app_list")
             attachment = authenticate.get_apps(message)
             your_apps = attachment.slack()
             self.reply("Here are the apps you have access to: ",
                        message=message,
                        attachments=your_apps)
     else:
         self.reply(
             'I could not authenticate you. Please make sure your "Full name"'
             ' is in your Slack profile and matches your Planning Center Profile.'
         )
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
 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))
Ejemplo n.º 4
0
 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))
Ejemplo n.º 5
0
 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))