Skip to content

Commit

Permalink
update 贡献者们
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien8261 committed Aug 1, 2024
1 parent 83e86b1 commit c024f69
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 53 deletions.
100 changes: 100 additions & 0 deletions docs/components/chargeThanks.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<template>
<div class="user-list">
<template v-for="item in data">
<div class="user" :class="{ small: !displayUserName }"
v-if="item['all_sum_amount'] >= min && item['all_sum_amount'] < max">
<img class="avatar" :src="item.user.avatar" :alt="item.user.name">
<div class="user-name" v-if="displayUserName">
<span class="name">{{ item.user.name }}</span>
<span class="amount">¥{{ item.all_sum_amount }}</span>
</div>
</div>
</template>
</div>
</template>

<script>
import axios from 'axios'
export default {
name: 'chargeThanks',
props: {
displayUserName: Boolean,
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: Infinity
}
},
methods: {
get_sponsors: function () {
axios.get('https://server.amiyabot.com:10001/get_sponsors').then(res => {
this.data = JSON.parse(res.data)
this.data.sort((a, b) => {
return b.all_sum_amount - a.all_sum_amount
})
})
}
},
data() {
return {
data: []
}
},
mounted() {
this.get_sponsors()
}
}
</script>

<style scoped>
.user-list {
display: flex;
flex-wrap: wrap;
}
.user {
display: flex;
align-items: center;
margin-bottom: 5px;
}
.user:not(.small) {
width: 25%;
}
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
border: 1px solid #b74ec9;
margin-left: 5px;
}
.small .avatar {
width: 40px;
height: 40px;
}
.user-name {
width: calc(100% - 85px);
margin: 0 20px 0 10px;
display: flex;
flex-direction: column;
}
.user-name > .name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.amount {
font-size: 12px;
font-weight: bold;
color: #ff9800;
}
</style>
88 changes: 38 additions & 50 deletions docs/components/specialThanks.vue
Original file line number Diff line number Diff line change
@@ -1,59 +1,52 @@
<template>
<div class="user-list">
<template v-for="item in data">
<div class="user" :class="{ small: !displayUserName }"
v-if="item['all_sum_amount'] >= min && item['all_sum_amount'] < max">
<img class="avatar" :src="item.user.avatar" :alt="item.user.name">
<div class="user-name" v-if="displayUserName">
<span class="name">{{ item.user.name }}</span>
<span class="amount">¥{{ item.all_sum_amount }}</span>
</div>
<div class="user">
<img class="avatar" src="https://q1.qlogo.cn/g?b=qq&nk=1391939232&s=640" alt="">
<div class="user-name">
<span class="name" style="color: #f44336; font-size: 18px">幕后大佬</span>
<span class="desc">顶级的存在!支撑兔兔的所有!</span>
</div>
</template>
</div>
<div class="user">
<img class="avatar" src="https://q1.qlogo.cn/g?b=qq&nk=3061243068&s=640" alt="">
<div class="user-name">
<span class="name">Initial heart</span>
<span class="desc">社区风纪委员、Logo 贡献者</span>
</div>
</div>
<div class="user">
<img class="avatar" src="https://q1.qlogo.cn/g?b=qq&nk=457586001&s=640" alt="">
<div class="user-name">
<span class="name">hsyhhssyy</span>
<span class="desc">插件作者、兔兔 AI 维护人</span>
</div>
</div>
<div class="user">
<img class="avatar" src="https://q1.qlogo.cn/g?b=qq&nk=2300652404&s=640" alt="">
<div class="user-name">
<span class="name">天基</span>
<span class="desc">插件作者、插件服务器贡献者</span>
</div>
</div>
<div class="user">
<img class="avatar" src="https://q1.qlogo.cn/g?b=qq&nk=1961411984&s=640" alt="">
<div class="user-name">
<span class="name">.Tdp</span>
<span class="desc">插件作者、百度图像识别接口贡献者</span>
</div>
</div>
</div>
</template>

<script>
import axios from 'axios'
export default {
name: 'specialThanks',
props: {
displayUserName: Boolean,
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: Infinity
}
},
methods: {
get_sponsors: function () {
axios.get('https://server.amiyabot.com:8020/get_sponsors').then(res => {
this.data = JSON.parse(res.data)
this.data.sort((a, b) => {
return b.all_sum_amount - a.all_sum_amount
})
})
}
},
data() {
return {
data: []
}
},
mounted() {
this.get_sponsors()
}
name: 'specialThanks'
}
</script>

<style scoped>
.user-list {
display: flex;
flex-wrap: wrap;
}
.user {
Expand All @@ -62,10 +55,6 @@ export default {
margin-bottom: 5px;
}
.user:not(.small) {
width: 25%;
}
.avatar {
width: 50px;
height: 50px;
Expand All @@ -92,9 +81,8 @@ export default {
white-space: nowrap;
}
.amount {
font-size: 12px;
.desc {
font-weight: bold;
color: #ff9800;
color: #b74ec9;
}
</style>
35 changes: 35 additions & 0 deletions docs/develop/adapters/qqChannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

按照 [基础指南](/develop/basic/index.md) 创建的机器人即为 QQ 频道机器人,无需额外的适配器。

## 事件分片

考虑到开发者事件接收时可以实现负载均衡,QQ
提供了分片逻辑,事件通知会落在不同的分片上,可参考官方文档 [分片连接LoadBalance](https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/event-emit.html#%E5%88%86%E7%89%87%E8%BF%9E%E6%8E%A5loadbalance)
了解分片机制。

创建分片连接需要使用分片适配器 `qq_guild_shards`

```python
from amiyabot.adapters.tencent.qqGuild import qq_guild_shards

bot1 = AmiyaBot(appid='...', token='...', adapter=qq_guild_shards(0, 2))
bot2 = AmiyaBot(appid='...', token='...', adapter=qq_guild_shards(1, 2))
```

::: danger 注意<br>
每个分片的启动应当**按顺序缓慢进行**,切勿同时启动,以免 gateway 返回的信息一致造成连接失败。

```python
# 仅作示意,实际上每个分片应当是独立的服务。
def start():
asyncio.create_task(bot1.start())
time.sleep(2)
asyncio.create_task(bot2.start())
```

:::

`qq_guild_shards` 参数

| 参数名 | 类型 | 释义 | 默认值 |
|-------------|-----|-------------|-----|
| shard_index | int | 分片下标,从 0 开始 | |
| shards | int | 分片总数 | |

## 沙箱环境

使用 `QQGuildSandboxBotInstance` 适配器将 API 调用更改为沙箱环境。沙箱环境只会收到测试频道的事件,且调用 openapi 仅能操作测试频道。
Expand Down
34 changes: 34 additions & 0 deletions docs/develop/adapters/qqGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,44 @@ client_secret = '******' # 密钥
bot = AmiyaBot(appid='******', token='******', adapter=qq_group(client_secret))
```

`qq_group` 参数

| 参数名 | 类型 | 释义 | 默认值 |
|-------------------------------|----------------------------|-------------|------------------------------|
| client_secret | str | 机器人密钥 | |
| default_chain_builder | ChainBuilder | 默认消息构建器 | None |
| default_chain_builder_options | QQGroupChainBuilderOptions | 默认消息构建器参数 | QQGroupChainBuilderOptions() |
| shard_index | int | 分片下标,从 0 开始 | 0 |
| shards | int | 分片总数 | 1 |

- 在机器人启动时,资源服务也会一同启动。
- 默认的资源服务是端口单例的,实例化多个 QQ 群聊适配器 AmiyaBot 或使用 [多账号](/develop/basic/multipleAccounts.html)
时,同一个端口的资源服务会相互共享。

## 事件分片

考虑到开发者事件接收时可以实现负载均衡,QQ
提供了分片逻辑,事件通知会落在不同的分片上,可参考官方文档 [分片连接LoadBalance](https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/event-emit.html#%E5%88%86%E7%89%87%E8%BF%9E%E6%8E%A5loadbalance)
了解分片机制。

```python
bot1 = AmiyaBot(appid='...', token='...', adapter=qq_group(client_secret, shard_index=0, shards=2))
bot2 = AmiyaBot(appid='...', token='...', adapter=qq_group(client_secret, shard_index=1, shards=2))
```

::: danger 注意<br>
每个分片的启动应当**按顺序缓慢进行**,切勿同时启动,以免 gateway 返回的信息一致造成连接失败。

```python
# 仅作示意,实际上每个分片应当是独立的服务。
def start():
asyncio.create_task(bot1.start())
time.sleep(2)
asyncio.create_task(bot2.start())
```

:::

### 修改资源服务配置

引入 `QQGroupChainBuilderOptions` 修改默认的资源服务配置。
Expand Down
13 changes: 10 additions & 3 deletions docs/sponsor.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ aside: false
---

<script setup>
import specialThanks from './components/specialThanks.vue'
import specialThanks from './components/specialThanks.vue';
import chargeThanks from './components/chargeThanks.vue';
</script>

# 赞助
Expand All @@ -17,10 +18,16 @@ AmiyaBot 也给你带去了快乐吧。

## 特别鸣谢

感谢各位对 AmiyaBot 社区做出的贡献,是大家共同塑造了 AmiyaBot 社区的繁荣。期待未来我们能携手创造更多可能!🌹

<specialThanks/>

## 充电鸣谢

你们的鼎力支持让我们感到创作 AmiyaBot 项目是值得的。感谢有你,让 AmiyaBot 秉承初衷。❤️

<specialThanks :min="0" :displayUserName="true"/>
<chargeThanks :min="0" :displayUserName="true"/>

打赏请前往[爱发电主页](https://afdian.net/a/amiyabot)
打赏请前往[爱发电主页](https://afdian.com/a/amiyabot)

<img style="width: 400px" src="./assets/5a4a07cc67f556288d3df2e9029fc14.jpg" alt="image">

0 comments on commit c024f69

Please sign in to comment.