-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move optional chat features into dedicated apps
- Loading branch information
1 parent
f0b1d05
commit ca893a3
Showing
8 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.apps import AppConfig | ||
|
||
|
||
class AppHomeConfig(AppConfig): | ||
name = 'django_slackbot.app_home' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
from urllib.parse import urlencode, parse_qs, urlparse | ||
|
||
from slackblocks import SectionBlock, HeaderBlock, DividerBlock | ||
from slackblocks.messages import BaseMessage | ||
|
||
from django_slackbot.chat import app | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class ViewMessage(BaseMessage): | ||
def _resolve(self): | ||
result = {**super()._resolve()} | ||
result.pop("mrkdwn", None) | ||
result.pop("text", None) | ||
return result | ||
|
||
@app.event("app_home_opened") | ||
def app_home_opened(event, ack, client): | ||
ack() | ||
details = client.auth_test() | ||
channels = client.users_conversations(types="public_channel,private_channel") | ||
channellist = '' | ||
for channel in channels['channels']: | ||
channellist += f"* <#{channel['id']}>\n" | ||
view = ViewMessage(blocks=[ | ||
HeaderBlock(f":wave: Hello, I'm {details['user']}!"), | ||
DividerBlock(), | ||
SectionBlock("\n*Active in Channels:*"), | ||
DividerBlock(), | ||
SectionBlock(f"{channellist}"), | ||
]) | ||
client.views_publish( | ||
user_id = event['user'], | ||
view = dict(type="home", **view) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
|
||
class FrinkiacConfig(AppConfig): | ||
name = 'examples.frinkiac' | ||
name = 'django_slackbot.frinkiac' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters