Skip to content

Commit

Permalink
Merge pull request berty#2862 from clegirar/fix/implem-bots
Browse files Browse the repository at this point in the history
fix: implem bots
  • Loading branch information
clegirar authored Dec 18, 2020
2 parents 0de0e5e + 9af0f9a commit d0a7494
Show file tree
Hide file tree
Showing 18 changed files with 424 additions and 501 deletions.
21 changes: 14 additions & 7 deletions config/config.gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ berty:
link: "https://berty.tech/id#contact/oZBLFkhRFWg9NXmy8wtjzZKeeUwfaWQVkUXfNY6h9z4QnGXuXSox8zs2yXeFHzt9DKJ8B4WHy7Zjy1g8tSat6ee2Jh7vp4J/name=BetaBot"
description: "Official BetaBot"
kind: "Bot"
suggestion: true
#icon:
testbot:
name: "TestBot"
link: "https://berty.tech/id#contact/oZBLG8gg1RTwCW2u1AxA44dT1Lum2PAr2nBra6WdmTpozq7vdDkae9FjyCW3QZ86AE9pMAudh4GKTfNj1jELcdvtJy44Rbp/name=TestBot"
description: "Official TestBot"
kind: "Bot"
suggestion: false
#icon:
betabot-dev:
name: "BetaBot Dev"
link: "https://berty.tech/id#contact/oZBLFQQTqmZ25yvcRRUVgzzZCpDY7YAVXDEz3g8kmwcSPCmnQrqiMbLrfSp1GRLaNBX6ZRarid8jkSUX4yQYL4oBZcLDtFY/name=BetaBot-Dev"
description: "BetaBot-Dev"
kind: "Bot"
suggestion: true
#icon:
testbot-dev:
name: "TestBot Dev"
link: "https://berty.tech/id#contact/oZBLFG6fwy21Dn4o511HC6ghxEghB5apq2QhjFepXCkbhfCWjzvRzhetVCGYwWhCtrWVL1TmExtHvdgGBvx1WK1RnXTdato/name=TestBot-Dev"
description: "TestBot-Dev"
kind: "Bot"
suggestion: false
#icon:
#support:
#staff:
Expand All @@ -32,14 +36,17 @@ berty:
link: "https://berty.tech/id#group/5QdUv6Fn3uvi3AchNcqFECaZvngDzWGUJV4wntYCWuYyjXrNi4ykvnP2ZCeWA1YLTmCSFbZaimXzp8rZtkKqby8nGv7S2AXyJPggo3aMghJS3rpeuDx6pbbNqEoNXJK67pWVpcLB6VrXM54zRNbi4zhEsLdATGzguWoruShcRHzFpuP75nyvRnXnfRaHPjdbyC/name=Dev+Test"
name: "Dev Test"
description: "Simple Conversation with Replication"
suggestion: false
dev-test-2:
link: "https://berty.tech/id#group/5QdUv6Fn3uwSPQZpLUXcNpQ24bR9y1TUK6xJfE9khJo4jrP8jF4QfdgpTT73Us58y6XZhtvJHLDCouXfgsKDxXqZAsfLDhUZLb48PDcBYYVUk7nzxh1MKh5a6Ug1bP4KpdrVDYQx1gCZA4HZavEUgUBbC1pYBZ2DaY27sCMfqxpt79RjZCBwmVqW1DbbuYCUoc/name=Dev+Test+2"
name: "Dev Test 2"
description: "Simple Conversation with Replication"
suggestion: false
group-with-passphrase:
link: "https://berty.tech/id#enc/3KE388cyt693i3Y8FUK1HMwr6BQGuckRx8ypxdtmrFrmMvgb8JNeu8L8BSkL6MbNjyFR4jSgEDmerbmGSXPsoVrbmrprcKX3PG3a2EY4jF2D7BUUdg1kDpxewAcHMyVRW66yMTe29G6sjuJ8C2MjEUWMWT7oX3jv94aCvWQbomePYL6ff9Bm8Msbe3UXBgqN6Wff9QqEScsMG9WnKUQQLtKxSqwN59etjrz/name=group-with-passphrase"
name: "Group with passphrase (test)"
description: "A demo group with a passphrase"
suggestion: false
p2p:
rdvp:
# svc fr
Expand Down
21 changes: 14 additions & 7 deletions go/internal/config/config.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go/pkg/protocoltypes/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ type Config struct {
Name string `json:"name"`
Description string `json:"description"`
Kind string `json:"kind"`
Suggestion bool `json:"suggestion"`
} `json:"contacts"`
Conversations map[string]struct {
Link string `json:"link"`
Name string `json:"name"`
Description string `json:"description"`
Suggestion bool `json:"suggestion"`
} `json:"conversations"`
} `json:"berty"`
P2P struct {
Expand Down
32 changes: 12 additions & 20 deletions js/packages/components/avatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ import Jdenticon from 'react-native-jdenticon'
import { Image, View, ViewStyle } from 'react-native'

import { useStyles } from '@berty-tech/styles'
import {
useAccount,
useContact,
useMember,
useConversation,
Maybe,
usePersistentOptions,
} from '@berty-tech/store/hooks'
import { useAccount, useContact, useMember, useConversation, Maybe } from '@berty-tech/store/hooks'
import beapi from '@berty-tech/api'

import AttachmentImage from './AttachmentImage'
Expand Down Expand Up @@ -70,9 +63,17 @@ const GenericAvatar: React.FC<{
)
}

const BetabotAvatar: React.FC<{ size: number; style?: AvatarStyle }> = ({ size, style }) => {
export const BotAvatar: React.FC<{ size: number; style?: AvatarStyle }> = ({ size, style }) => {
const [{ border, flex, background }] = useStyles()

const padding = Math.round(size / 15)
let innerSize = Math.round(size - 2 * padding)
if (innerSize % 2) {
innerSize--
}
let iconSize = Math.round(innerSize - innerSize / 8)
if (iconSize % 2) {
iconSize--
}
return (
<View
style={[
Expand All @@ -88,7 +89,7 @@ const BetabotAvatar: React.FC<{ size: number; style?: AvatarStyle }> = ({ size,
},
]}
>
<Logo width={size - 15} height={size - 15} style={{ right: -1, top: -1 }} />
<Logo width={iconSize} height={iconSize} style={{ right: -2, top: -1 }} />
</View>
)
}
Expand All @@ -111,15 +112,6 @@ export const ContactAvatar: React.FC<{
style?: AvatarStyle
}> = ({ publicKey, size, style }) => {
const contact = useContact(publicKey)
const persistOpts = usePersistentOptions()

if (
persistOpts.betabot.convPk &&
publicKey?.toString() === persistOpts.betabot.convPk.toString()
) {
return <BetabotAvatar size={size} style={style} />
}

return (
<GenericAvatar
cid={contact?.avatarCid}
Expand Down
14 changes: 11 additions & 3 deletions js/packages/components/chat/ContactSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Text } from '@ui-kitten/components'
import { useTranslation } from 'react-i18next'

import { useStyles } from '@berty-tech/styles'
import { useContacts } from '@berty-tech/store/hooks'
import { useContacts, useMsgrContext } from '@berty-tech/store/hooks'
import { useNavigation, ScreenProps } from '@berty-tech/navigation'

import { ButtonSetting } from '../shared-components/SettingsButtons'
import { FingerprintContent } from '../shared-components/FingerprintContent'
import { TabBar } from '../shared-components/TabBar'
import HeaderSettings from '../shared-components/Header'
import { SwipeNavRecognizer } from '../shared-components/SwipeNavRecognizer'
import { ContactAvatar } from '../avatars'
import { BotAvatar, ContactAvatar } from '../avatars'

const ContactSettingsHeaderContent: React.FC = ({ children }) => {
const [{ margin }] = useStyles()
Expand All @@ -34,6 +34,10 @@ const SelectedContent: React.FC<{ contentName: string; publicKey: string }> = ({
const ContactSettingsHeader: React.FC<{ contact: any }> = ({ contact }) => {
const [{ border, background, padding, row, absolute, text }] = useStyles()
const [selectedContent, setSelectedContent] = useState('Fingerprint')
const ctx = useMsgrContext()
const isSuggestion = Object.values(ctx.persistentOptions?.suggestions).find(
(v: any) => v.pk === contact?.publicKey,
)
const { t } = useTranslation()

return (
Expand All @@ -47,7 +51,11 @@ const ContactSettingsHeader: React.FC<{ contact: any }> = ({ contact }) => {
]}
>
<View style={[row.item.justify, absolute.scale({ top: -50 })]}>
<ContactAvatar size={100} publicKey={contact.publicKey} />
{isSuggestion ? (
<BotAvatar size={100} />
) : (
<ContactAvatar size={100} publicKey={contact.publicKey} />
)}
</View>
<View style={[padding.horizontal.medium, padding.bottom.medium, padding.top.scale(65)]}>
<Text style={[text.size.big, text.color.black, text.align.center, text.bold.small]}>
Expand Down
Loading

0 comments on commit d0a7494

Please sign in to comment.