@@ -36,27 +36,77 @@ pip install stream-chat
3636
3737### Quickstart
3838
39+ #### Sync
40+
3941``` python
40- chat = StreamChat(api_key = " STREAM_KEY" , api_secret = " STREAM_SECRET" )
42+ from stream_chat import StreamChat
43+
44+
45+ def main ():
46+ chat = StreamChat(api_key = " STREAM_KEY" , api_secret = " STREAM_SECRET" )
47+
48+ # add a user
49+ chat.update_user({" id" : " chuck" , " name" : " Chuck" })
4150
42- # add a user
43- chat.update_user({" id" : " chuck" , " name" : " Chuck" })
51+ # create a channel about kung-fu
52+ channel = chat.channel(" messaging" , " kung-fu" )
53+ channel.create(" chuck" )
4454
45- # create a channel about kung-fu
46- channel = chat.channel(" messaging" , " kung-fu" )
47- channel.create(" chuck" )
55+ # add a first message to the channel
56+ channel.send_message({" text" : " AMA about kung-fu" }, " chuck" )
4857
49- # add a first message to the channel
50- channel.send_message({" text" : " AMA about kung-fu" }, " chuck" )
58+
59+ if __name__ == ' __main__' :
60+ main()
61+
62+ ```
63+
64+ #### Async
65+
66+ ``` python
67+ import asyncio
68+ from stream_chat import StreamChatAsync
69+
70+
71+ async def main ():
72+ async with StreamChatAsync(api_key = " STREAM_KEY" , api_secret = " STREAM_SECRET" ) as chat:
73+ # add a user
74+ await chat.update_user({" id" : " chuck" , " name" : " Chuck" })
75+
76+ # create a channel about kung-fu
77+ channel = chat.channel(" messaging" , " kung-fu" )
78+ await channel.create(" chuck" )
79+
80+ # add a first message to the channel
81+ await channel.send_message({" text" : " AMA about kung-fu" }, " chuck" )
82+
83+
84+ if __name__ == ' __main__' :
85+ loop = asyncio.get_event_loop()
86+ try :
87+ loop.run_until_complete(main())
88+ finally :
89+ loop.run_until_complete(loop.shutdown_asyncgens())
90+ loop.close()
5191
5292```
5393
5494### Contributing
5595
96+ Install pytest and pytest-asyncio
97+
98+ ```
99+ pip install pytest
100+ pip install pytest-asyncio
101+ ```
102+
56103First, make sure you can run the test suite. Tests are run via py.test
57104
58105``` bash
59- STREAM_KEY=my_api_key STREAM_SECRET=my_api_secret py.test stream_chat/ -v
106+ export STREAM_KEY=my_api_key
107+ export STREAM_SECRET=my_api_secret
108+
109+ make test
60110```
61111
62112Install black and pycodestyle
@@ -66,6 +116,12 @@ pip install black
66116pip install pycodestyle
67117```
68118
119+ Run linters
120+
121+ ``` bash
122+ make lint
123+ ```
124+
69125
70126### Releasing a new version
71127
0 commit comments