{python}

Introduction to Python - Lecture 1

Zohair ul Hasan

Meet the Team

Instructor

Zohair ul Hasan

Teacher Assistant

M. Hamza Malik

Course Requirements

  • Personal Laptop
  • Pen and paper (optionally use your laptop to make notes)
  • WhatsApp
  • A willingness to learn 

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Slack Office Hours Bot

Slack Office Hours Bot

from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
import config


class SlackBot:
    def __init__(self, client: WebClient) -> None:
        self.client = client

    def post_message(self, channel_name: str, text: str) -> None:
        channel_id = self.get_channel_id_from_name(channel_name)
        try:
            print("Posting message to channel: {}".format(channel_name))
            response = self.client.chat_postMessage(
                channel=channel_id, text=text)
            assert response.data.get("ok")

        except SlackApiError as e:
            # You will get a SlackApiError if "ok" is False
            assert e.response["error"]

    def get_channel_id_from_name(self, channel_name: str):
        print("Getting channel ID for channel name: {}".format(channel_name))
        response = self.client.conversations_list()
        channels = response["channels"]
        for channel in channels:
            if channel["name"] == channel_name:
                return channel["id"]
                
if __name__ == "__main__":
    print("Starting script...")
    client = WebClient(config.SLACK_TOKEN)

    bot = SlackBot(client)
    bot.post_message(
        config.CHANNEL,
        "Hi everyone. My office hours are now live from {} - {} at {}. Feel free to join if you have any questions.".format(
            config.START_TIME, config.END_TIME, config.ZOOM_LINK
        ),
    

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Timesheet Autofill

Timesheet Autofill

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Drexel Course Availability Notifier

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Drexel Scheduler

 

Drexel Scheduler

 

Drexel Scheduler

 

Drexel Scheduler

 

Drexel Scheduler

 

Drexel Scheduler

 

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

Examples of how I used programming to make my life easier

Slack Office Hours Bot

Timesheet Autofill

Drexel Course Availability Notifier

Drexel Scheduler

 

And lots more!

Your turn!!

Come up with ideas of automation on your own

 

Do not worry about actually implementing them. Think of things you *think* a computer should be able to do for you and write it on a piece of paper

Programming is NOT easy

Course Website

Setting up your development environment

Follow the instructions at https://itp.zohair.dev/activities/replit-setup to set up your development environment. This is primarily where you will be coding