Skip to content

Commit d9183dc

Browse files
abhishek-jaisinghRodneyU215
authored andcommitted
Fix Indentation of Code Snippets in README.md (#525)
1 parent 128305a commit d9183dc

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ Slack provide a Web API that gives you the ability to build applications that in
8181
One of the most common use-cases is sending a message to Slack. If you want to send a message as your app, or as a user, this method can do both. In our examples, we specify the channel name, however it is recommended to use the `channel_id` where possible.
8282

8383
```python
84-
import os
85-
import slack
84+
import os
85+
import slack
8686

87-
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
87+
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
8888

89-
response = client.chat_postMessage(
90-
channel='#random',
91-
text="Hello world!")
92-
assert response["ok"]
93-
assert response["message"]["text"] == "Hello world!"
89+
response = client.chat_postMessage(
90+
channel='#random',
91+
text="Hello world!")
92+
assert response["ok"]
93+
assert response["message"]["text"] == "Hello world!"
9494
```
9595

9696
Here we also ensure that the response back from Slack is a successful one and that the message is the one we sent by using the `assert` statement.
@@ -100,15 +100,15 @@ Here we also ensure that the response back from Slack is a successful one and th
100100
We've changed the process for uploading files to Slack to be much easier and straight forward. You can now just include a path to the file directly in the API call and upload it that way. You can find the details on this api call [here][files.upload]
101101

102102
```python
103-
import os
104-
import slack
103+
import os
104+
import slack
105105

106-
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
106+
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
107107

108-
response = client.files_upload(
109-
channels='#random',
110-
file="my_file.pdf")
111-
assert response["ok"]
108+
response = client.files_upload(
109+
channels='#random',
110+
file="my_file.pdf")
111+
assert response["ok"]
112112
```
113113

114114
### Basic Usage of the RTM Client
@@ -129,28 +129,28 @@ information it receives. We also give you the ability to call our web client fro
129129
In our example below, we watch for a [message event][message-event] that contains "Hello" and if its received, we call the `say_hello()` function. We then issue a call to the web client to post back to the channel saying "Hi" to the user.
130130

131131
```python
132-
import os
133-
import slack
134-
135-
@slack.RTMClient.run_on(event='message')
136-
def say_hello(**payload):
137-
data = payload['data']
138-
web_client = payload['web_client']
139-
rtm_client = payload['rtm_client']
140-
if 'Hello' in data.get('text', []):
141-
channel_id = data['channel']
142-
thread_ts = data['ts']
143-
user = data['user']
144-
145-
web_client.chat_postMessage(
146-
channel=channel_id,
147-
text=f"Hi <@{user}>!",
148-
thread_ts=thread_ts
149-
)
132+
import os
133+
import slack
134+
135+
@slack.RTMClient.run_on(event='message')
136+
def say_hello(**payload):
137+
data = payload['data']
138+
web_client = payload['web_client']
139+
rtm_client = payload['rtm_client']
140+
if 'Hello' in data.get('text', []):
141+
channel_id = data['channel']
142+
thread_ts = data['ts']
143+
user = data['user']
144+
145+
web_client.chat_postMessage(
146+
channel=channel_id,
147+
text=f"Hi <@{user}>!",
148+
thread_ts=thread_ts
149+
)
150150

151-
slack_token = os.environ["SLACK_API_TOKEN"]
152-
rtm_client = slack.RTMClient(token=slack_token)
153-
rtm_client.start()
151+
slack_token = os.environ["SLACK_API_TOKEN"]
152+
rtm_client = slack.RTMClient(token=slack_token)
153+
rtm_client.start()
154154
```
155155

156156
### Async usage

0 commit comments

Comments
 (0)