[+] first commit
This commit is contained in:
commit
f3691178a4
30
.gitea/workflows/docker.yaml
Normal file
30
.gitea/workflows/docker.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: user/app:latest
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM golang:1.23.5 AS builder
|
||||||
|
ARG VERSION=prod
|
||||||
|
WORKDIR /app
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -o lucky
|
||||||
|
|
||||||
|
FROM debian:bullseye-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=builder /app/lucky .
|
||||||
|
COPY --from=builder /app/plugin ./plugin
|
||||||
|
|
||||||
|
CMD ["./lucky"]
|
49
main.go
Normal file
49
main.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/realSunyz/lucky-tgbot/plugin/reborn"
|
||||||
|
"github.com/realSunyz/lucky-tgbot/plugin/slash"
|
||||||
|
"github.com/realSunyz/lucky-tgbot/plugin/torf"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
tele "gopkg.in/telebot.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
pref := tele.Settings{
|
||||||
|
Token: os.Getenv("TOKEN"),
|
||||||
|
|
||||||
|
Poller: &tele.LongPoller{Timeout: 10 * time.Second},
|
||||||
|
}
|
||||||
|
|
||||||
|
rebornData, err := reborn.InitRebornList("plugin/reborn/countries.json")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := tele.NewBot(pref)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error creating bot: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b.Handle("/reborn", func(c tele.Context) error {
|
||||||
|
return reborn.Execute(c, rebornData)
|
||||||
|
})
|
||||||
|
// b.Handle("/info", info.Execute)
|
||||||
|
|
||||||
|
b.Handle(tele.OnText, func(c tele.Context) error {
|
||||||
|
inputText := c.Text()
|
||||||
|
|
||||||
|
if strings.HasPrefix(inputText, "/") {
|
||||||
|
return slash.Execute(c)
|
||||||
|
} else {
|
||||||
|
return torf.Execute(c)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
b.Start()
|
||||||
|
}
|
986
plugin/reborn/countries.json
Normal file
986
plugin/reborn/countries.json
Normal file
@ -0,0 +1,986 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"country": "阿富汗",
|
||||||
|
"population": 37172386
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿尔巴尼亚",
|
||||||
|
"population": 2866376
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿尔及利亚",
|
||||||
|
"population": 42228429
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "美属萨摩亚",
|
||||||
|
"population": 55465
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "安道尔",
|
||||||
|
"population": 77006
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "安哥拉",
|
||||||
|
"population": 30809762
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "安圭拉",
|
||||||
|
"population": 15094
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "南极洲",
|
||||||
|
"population": 1106
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "安提瓜和巴布达",
|
||||||
|
"population": 96286
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿根廷",
|
||||||
|
"population": 44494502
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "亚美尼亚",
|
||||||
|
"population": 2951776
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "亚美尼亚",
|
||||||
|
"population": 2951776
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿鲁巴",
|
||||||
|
"population": 105845
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "澳大利亚",
|
||||||
|
"population": 24982688
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "奥地利",
|
||||||
|
"population": 8840521
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿塞拜疆",
|
||||||
|
"population": 9939800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴哈马",
|
||||||
|
"population": 385640
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴林",
|
||||||
|
"population": 1569439
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "孟加拉国",
|
||||||
|
"population": 161356039
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴巴多斯",
|
||||||
|
"population": 286641
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "白俄罗斯",
|
||||||
|
"population": 9483499
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "比利时",
|
||||||
|
"population": 11433256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "伯利兹",
|
||||||
|
"population": 383071
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "贝宁",
|
||||||
|
"population": 11485048
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "百慕大",
|
||||||
|
"population": 63973
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "不丹",
|
||||||
|
"population": 754394
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "玻利维亚",
|
||||||
|
"population": 11353142
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "波斯尼亚和黑塞哥维那",
|
||||||
|
"population": 3323929
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "博茨瓦纳",
|
||||||
|
"population": 2254126
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "布维岛",
|
||||||
|
"population": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴西",
|
||||||
|
"population": 209469333
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "英属印度洋领土",
|
||||||
|
"population": 3500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "文莱",
|
||||||
|
"population": 428962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "保加利亚",
|
||||||
|
"population": 7025037
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "布基纳法索",
|
||||||
|
"population": 19751535
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "布隆迪",
|
||||||
|
"population": 11175378
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "佛得角",
|
||||||
|
"population": 555987
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "柬埔寨",
|
||||||
|
"population": 16249798
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "喀麦隆",
|
||||||
|
"population": 25216237
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "加拿大",
|
||||||
|
"population": 37057765
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "佛得角",
|
||||||
|
"population": 543767
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "开曼群岛",
|
||||||
|
"population": 64174
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "中非共和国",
|
||||||
|
"population": 4666377
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "乍得",
|
||||||
|
"population": 15477751
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "智利",
|
||||||
|
"population": 18729160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "中国",
|
||||||
|
"population": 1392730000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣诞岛",
|
||||||
|
"population": 1402
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "科科斯(基林)群岛",
|
||||||
|
"population": 596
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "哥伦比亚",
|
||||||
|
"population": 49648685
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "科摩罗",
|
||||||
|
"population": 832322
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "刚果共和国",
|
||||||
|
"population": 5244363
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "库克群岛",
|
||||||
|
"population": 17379
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "哥斯达黎加",
|
||||||
|
"population": 4999441
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "克罗地亚",
|
||||||
|
"population": 4087843
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "古巴",
|
||||||
|
"population": 11338138
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塞浦路斯",
|
||||||
|
"population": 1189265
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "捷克共和国",
|
||||||
|
"population": 10629928
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "丹麦",
|
||||||
|
"population": 5793636
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "吉布提",
|
||||||
|
"population": 958920
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "多米尼加",
|
||||||
|
"population": 71625
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "多米尼加共和国",
|
||||||
|
"population": 10627165
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "东帝汶",
|
||||||
|
"population": 1267972
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "厄瓜多尔",
|
||||||
|
"population": 17084357
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "埃及",
|
||||||
|
"population": 98423595
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "萨尔瓦多",
|
||||||
|
"population": 6420744
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "英格兰",
|
||||||
|
"population": 55619400
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "赤道几内亚",
|
||||||
|
"population": 1308974
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "厄立特里亚",
|
||||||
|
"population": 6213972
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "爱沙尼亚",
|
||||||
|
"population": 1321977
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "埃斯瓦蒂尼",
|
||||||
|
"population": 1136191
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "埃塞俄比亚",
|
||||||
|
"population": 109224559
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "福克兰群岛",
|
||||||
|
"population": 2840
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "法罗群岛",
|
||||||
|
"population": 48497
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "斐济群岛",
|
||||||
|
"population": 883483
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "芬兰",
|
||||||
|
"population": 5515525
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "法国",
|
||||||
|
"population": 66977107
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "法属圭亚那",
|
||||||
|
"population": 290691
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "法属波利尼西亚",
|
||||||
|
"population": 277679
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "法属南部领土",
|
||||||
|
"population": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "加蓬",
|
||||||
|
"population": 2119275
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "冈比亚",
|
||||||
|
"population": 2280102
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "格鲁吉亚",
|
||||||
|
"population": 3726549
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "德国",
|
||||||
|
"population": 82905782
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "加纳",
|
||||||
|
"population": 29767108
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "直布罗陀",
|
||||||
|
"population": 33718
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "希腊",
|
||||||
|
"population": 10731726
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "格林兰",
|
||||||
|
"population": 56025
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "格林纳达",
|
||||||
|
"population": 111454
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瓜德罗普",
|
||||||
|
"population": 395700
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "关岛",
|
||||||
|
"population": 165768
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "危地马拉",
|
||||||
|
"population": 17247807
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "几内亚",
|
||||||
|
"population": 12414318
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "几内亚比绍",
|
||||||
|
"population": 1874309
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圭亚那",
|
||||||
|
"population": 779004
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "海地",
|
||||||
|
"population": 11123176
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "赫德岛和麦克唐纳群岛",
|
||||||
|
"population": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "梵蒂冈",
|
||||||
|
"population": 825
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "洪都拉斯",
|
||||||
|
"population": 9587522
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "香港",
|
||||||
|
"population": 7451000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "匈牙利",
|
||||||
|
"population": 9775564
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "冰岛",
|
||||||
|
"population": 352721
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "印度",
|
||||||
|
"population": 1352617328
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "印度尼西亚",
|
||||||
|
"population": 267663435
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "伊朗",
|
||||||
|
"population": 81800269
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "伊拉克",
|
||||||
|
"population": 38433600
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "爱尔兰",
|
||||||
|
"population": 4867309
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "以色列",
|
||||||
|
"population": 8882800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "意大利",
|
||||||
|
"population": 60421760
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "科特迪瓦",
|
||||||
|
"population": 25069229
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "牙买加",
|
||||||
|
"population": 2934855
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "日本",
|
||||||
|
"population": 126529100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "约旦",
|
||||||
|
"population": 9956011
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "哈萨克斯坦",
|
||||||
|
"population": 18272430
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "肯尼亚",
|
||||||
|
"population": 51393010
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "基里巴斯",
|
||||||
|
"population": 115847
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "科威特",
|
||||||
|
"population": 4137309
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "吉尔吉斯斯坦",
|
||||||
|
"population": 6322800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "老挝",
|
||||||
|
"population": 7061507
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "拉脱维亚",
|
||||||
|
"population": 1927174
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "黎巴嫩",
|
||||||
|
"population": 6848925
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "莱索托",
|
||||||
|
"population": 2108132
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "利比里亚",
|
||||||
|
"population": 4818977
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "利比亚",
|
||||||
|
"population": 6678567
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "列支敦士登",
|
||||||
|
"population": 37910
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "立陶宛",
|
||||||
|
"population": 2801543
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "卢森堡",
|
||||||
|
"population": 607950
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "澳门",
|
||||||
|
"population": 631636
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "北马其顿",
|
||||||
|
"population": 2084367
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马达加斯加",
|
||||||
|
"population": 26262368
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马拉维",
|
||||||
|
"population": 18143315
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马来西亚",
|
||||||
|
"population": 31528585
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马尔代夫",
|
||||||
|
"population": 515696
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马里",
|
||||||
|
"population": 19077690
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马耳他",
|
||||||
|
"population": 484630
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马绍尔群岛",
|
||||||
|
"population": 58413
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马提尼克",
|
||||||
|
"population": 376480
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "毛里塔尼亚",
|
||||||
|
"population": 4403319
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "毛里求斯",
|
||||||
|
"population": 1265303
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "马约特",
|
||||||
|
"population": 270372
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "墨西哥",
|
||||||
|
"population": 126190788
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "密克罗尼西亚联邦",
|
||||||
|
"population": 112640
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "摩尔多瓦",
|
||||||
|
"population": 2706049
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "摩纳哥",
|
||||||
|
"population": 38682
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "蒙古",
|
||||||
|
"population": 3170208
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "黑山",
|
||||||
|
"population": 631219
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "蒙特塞拉特",
|
||||||
|
"population": 5900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "摩洛哥",
|
||||||
|
"population": 36029138
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "莫桑比克",
|
||||||
|
"population": 29495962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "缅甸",
|
||||||
|
"population": 53708395
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "纳米比亚",
|
||||||
|
"population": 2448255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瑙鲁",
|
||||||
|
"population": 12704
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "尼泊尔",
|
||||||
|
"population": 28087871
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "荷兰",
|
||||||
|
"population": 17231624
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "荷属安的列斯",
|
||||||
|
"population": 227049
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "新喀里多尼亚",
|
||||||
|
"population": 284060
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "新西兰",
|
||||||
|
"population": 4841000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "尼加拉瓜",
|
||||||
|
"population": 6465513
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "尼日尔",
|
||||||
|
"population": 22442948
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "尼日利亚",
|
||||||
|
"population": 195874740
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "纽埃",
|
||||||
|
"population": 1624
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "诺福克岛",
|
||||||
|
"population": 2169
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "朝鲜",
|
||||||
|
"population": 25549819
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "北爱尔兰",
|
||||||
|
"population": 1885400
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "北马里亚纳群岛",
|
||||||
|
"population": 56882
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "挪威",
|
||||||
|
"population": 5311916
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿曼",
|
||||||
|
"population": 4829483
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴基斯坦",
|
||||||
|
"population": 212215030
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "帕劳",
|
||||||
|
"population": 17907
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴勒斯坦",
|
||||||
|
"population": 4569087
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴拿马",
|
||||||
|
"population": 4176873
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴布亚新几内亚",
|
||||||
|
"population": 8606316
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "巴拉圭",
|
||||||
|
"population": 6956071
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "秘鲁",
|
||||||
|
"population": 31989256
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "菲律宾",
|
||||||
|
"population": 106651922
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "皮特凯恩",
|
||||||
|
"population": 67
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "波兰",
|
||||||
|
"population": 37974750
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "葡萄牙",
|
||||||
|
"population": 10283822
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "波多黎各",
|
||||||
|
"population": 3195153
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "卡塔尔",
|
||||||
|
"population": 2781677
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "留尼汪",
|
||||||
|
"population": 859959
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "罗马尼亚",
|
||||||
|
"population": 19466145
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "俄罗斯",
|
||||||
|
"population": 144478050
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "卢旺达",
|
||||||
|
"population": 12301939
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣赫勒拿",
|
||||||
|
"population": 6600
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣基茨和尼维斯",
|
||||||
|
"population": 52441
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣卢西亚",
|
||||||
|
"population": 181889
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣皮埃尔和密克隆",
|
||||||
|
"population": 5888
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣文森特和格林纳丁斯",
|
||||||
|
"population": 110210
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "萨摩亚",
|
||||||
|
"population": 196130
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣马力诺",
|
||||||
|
"population": 33785
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "圣多美和普林西比",
|
||||||
|
"population": 211028
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "沙特阿拉伯",
|
||||||
|
"population": 33699947
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "苏格兰",
|
||||||
|
"population": 5424800
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塞内加尔",
|
||||||
|
"population": 15854360
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塞尔维亚",
|
||||||
|
"population": 6963764
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塞舌尔",
|
||||||
|
"population": 96762
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塞拉利昂",
|
||||||
|
"population": 7650154
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "新加坡",
|
||||||
|
"population": 5638676
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "斯洛伐克",
|
||||||
|
"population": 5446771
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "斯洛文尼亚",
|
||||||
|
"population": 2073894
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "所罗门群岛",
|
||||||
|
"population": 652858
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "索马里",
|
||||||
|
"population": 15008154
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "南非",
|
||||||
|
"population": 57779622
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "南极洲南乔治亚岛和南桑威奇群岛",
|
||||||
|
"population": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "韩国",
|
||||||
|
"population": 51606633
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "南苏丹",
|
||||||
|
"population": 10975920
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "西班牙",
|
||||||
|
"population": 46796540
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "斯里兰卡",
|
||||||
|
"population": 21670000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "苏丹",
|
||||||
|
"population": 41801533
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "苏里南",
|
||||||
|
"population": 575991
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "斯瓦尔巴群岛和扬马延岛",
|
||||||
|
"population": 2572
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瑞典",
|
||||||
|
"population": 10175214
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瑞士",
|
||||||
|
"population": 8513227
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "叙利亚",
|
||||||
|
"population": 16906283
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "塔吉克斯坦",
|
||||||
|
"population": 9100837
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "坦桑尼亚",
|
||||||
|
"population": 56318348
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "泰国",
|
||||||
|
"population": 69428524
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "刚果民主共和国",
|
||||||
|
"population": 84068091
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "多哥",
|
||||||
|
"population": 7889094
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "托克劳",
|
||||||
|
"population": 1411
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "汤加",
|
||||||
|
"population": 103197
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "特立尼达和多巴哥",
|
||||||
|
"population": 1389858
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "突尼斯",
|
||||||
|
"population": 11565204
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "土耳其",
|
||||||
|
"population": 82319724
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "土库曼斯坦",
|
||||||
|
"population": 5850908
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "特克斯和凯科斯群岛",
|
||||||
|
"population": 37665
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "图瓦卢",
|
||||||
|
"population": 11508
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "乌干达",
|
||||||
|
"population": 42723139
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "乌克兰",
|
||||||
|
"population": 44622516
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "阿联酋",
|
||||||
|
"population": 9630959
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "英国",
|
||||||
|
"population": 66460344
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "美国",
|
||||||
|
"population": 326687501
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "美国本土外岛",
|
||||||
|
"population": 300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "乌拉圭",
|
||||||
|
"population": 3449299
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "乌兹别克斯坦",
|
||||||
|
"population": 32955400
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瓦努阿图",
|
||||||
|
"population": 292680
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "委内瑞拉",
|
||||||
|
"population": 28870195
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "越南",
|
||||||
|
"population": 95540395
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "英属维尔京群岛",
|
||||||
|
"population": 29802
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "美属维尔京群岛",
|
||||||
|
"population": 106977
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "威尔士",
|
||||||
|
"population": 3139000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "瓦利斯和富图纳群岛",
|
||||||
|
"population": 15289
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "西撒哈拉",
|
||||||
|
"population": 652271
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "也门",
|
||||||
|
"population": 28498687
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "赞比亚",
|
||||||
|
"population": 17351822
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "津巴布韦",
|
||||||
|
"population": 14439018
|
||||||
|
}
|
||||||
|
]
|
77
plugin/reborn/main.go
Normal file
77
plugin/reborn/main.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package reborn
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
tele "gopkg.in/telebot.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Country struct {
|
||||||
|
Name string `json:"country"`
|
||||||
|
Pop int64 `json:"population"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RebornData struct {
|
||||||
|
List []Country
|
||||||
|
TotalPop int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitRebornList(filePath string) (*RebornData, error) {
|
||||||
|
rawJson, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to read file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var countries []Country
|
||||||
|
if err = json.Unmarshal(rawJson, &countries); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to parse JSON: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
totalPop := int64(0)
|
||||||
|
for _, country := range countries {
|
||||||
|
totalPop += country.Pop
|
||||||
|
}
|
||||||
|
|
||||||
|
return &RebornData{
|
||||||
|
List: countries,
|
||||||
|
TotalPop: totalPop,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (data *RebornData) randCountry(r *rand.Rand) (Country, error) {
|
||||||
|
randNum := r.Int63n(data.TotalPop)
|
||||||
|
|
||||||
|
for _, country := range data.List {
|
||||||
|
if randNum < country.Pop {
|
||||||
|
return country, nil
|
||||||
|
}
|
||||||
|
randNum -= country.Pop
|
||||||
|
}
|
||||||
|
|
||||||
|
return Country{}, fmt.Errorf("failed to select a country")
|
||||||
|
}
|
||||||
|
|
||||||
|
func randGender(r *rand.Rand) string {
|
||||||
|
genders := []string{"男孩子", "女孩子", " MtF", " FtM", "萝莉", "正太", "武装直升机", "沃尔玛购物袋", "狗狗", "猫猫"}
|
||||||
|
return genders[r.Intn(len(genders))]
|
||||||
|
}
|
||||||
|
|
||||||
|
func Execute(c tele.Context, data *RebornData) error {
|
||||||
|
source := rand.NewSource(time.Now().UnixNano())
|
||||||
|
r := rand.New(source)
|
||||||
|
|
||||||
|
country, err := data.randCountry(r)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
gender := randGender(r)
|
||||||
|
|
||||||
|
outputText := fmt.Sprintf("投胎成功!\n你出生在%s,是%s。", country.Name, gender)
|
||||||
|
|
||||||
|
return c.Reply(outputText)
|
||||||
|
}
|
107
plugin/slash/main.go
Normal file
107
plugin/slash/main.go
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
package slash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
|
tele "gopkg.in/telebot.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func isASCII(s string) bool {
|
||||||
|
for _, r := range s {
|
||||||
|
if r > unicode.MaxASCII {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func isValid(inputText string) bool {
|
||||||
|
if len(inputText) < 2 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if isASCII(inputText[:2]) && !strings.HasPrefix(inputText, "/$") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func genLink(c tele.Context) (string, string) {
|
||||||
|
genName := func(firstName, lastName string) string {
|
||||||
|
if lastName != "" {
|
||||||
|
return fmt.Sprintf("%s %s", firstName, lastName)
|
||||||
|
}
|
||||||
|
return firstName
|
||||||
|
}
|
||||||
|
|
||||||
|
senderURI := fmt.Sprintf("tg://user?id=%d", c.Message().Sender.ID)
|
||||||
|
senderName := genName(c.Message().Sender.FirstName, c.Message().Sender.LastName)
|
||||||
|
|
||||||
|
// Message is sent on behalf of a Channel or Group
|
||||||
|
if c.Message().SenderChat != nil {
|
||||||
|
chatID := -1 * (c.Message().SenderChat.ID % 10000000000)
|
||||||
|
senderURI = fmt.Sprintf("https://t.me/c/%d", chatID)
|
||||||
|
senderName = c.Message().SenderChat.Title
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message is NOT a reply to others by default
|
||||||
|
replyToURI := ""
|
||||||
|
replyToName := "自己"
|
||||||
|
|
||||||
|
// Message is a reply to others
|
||||||
|
if c.Message().IsReply() {
|
||||||
|
replyToURI = fmt.Sprintf("tg://user?id=%d", c.Message().ReplyTo.Sender.ID)
|
||||||
|
replyToName = genName(c.Message().ReplyTo.Sender.FirstName, c.Message().ReplyTo.Sender.LastName)
|
||||||
|
|
||||||
|
if c.Message().ReplyTo.SenderChat != nil {
|
||||||
|
chatID := -1 * (c.Message().ReplyTo.SenderChat.ID % 10000000000)
|
||||||
|
replyToURI = fmt.Sprintf("https://t.me/c/%d", chatID)
|
||||||
|
replyToName = c.Message().ReplyTo.SenderChat.Title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.Message().Entities) != 0 {
|
||||||
|
if c.Message().Entities[0].Type == "text_mention" {
|
||||||
|
replyToURI = fmt.Sprintf("tg://user?id=%d", c.Message().Entities[0].User.ID)
|
||||||
|
replyToName = genName(c.Message().Entities[0].User.FirstName, c.Message().Entities[0].User.LastName)
|
||||||
|
} else if c.Message().Entities[0].Type == "mention" {
|
||||||
|
t := strings.Index(c.Text(), " @")
|
||||||
|
if t != -1 {
|
||||||
|
pubUserName := c.Text()[t:]
|
||||||
|
replyToName = strings.TrimSpace(pubUserName)
|
||||||
|
}
|
||||||
|
replyToURI = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
senderLink := fmt.Sprintf("[%s](%s)", senderName, senderURI)
|
||||||
|
replyToLink := fmt.Sprintf("[%s](%s)", replyToName, replyToURI)
|
||||||
|
|
||||||
|
return senderLink, replyToLink
|
||||||
|
}
|
||||||
|
|
||||||
|
func Execute(c tele.Context) error {
|
||||||
|
inputText := c.Text()
|
||||||
|
|
||||||
|
if !isValid(inputText) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
actions := strings.SplitN(strings.Replace(inputText, "$", "", 1)[1:], " ", 3)
|
||||||
|
|
||||||
|
if len(actions) != 1 && len(actions) != 2 && len(actions) != 3 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
senderLink, replyToLink := genLink(c)
|
||||||
|
|
||||||
|
outputText := fmt.Sprintf("%s %s了 %s", senderLink, actions[0], replyToLink)
|
||||||
|
if len(actions) == 2 || len(actions) == 3 {
|
||||||
|
outputText = fmt.Sprintf("%s %s了 %s %s", senderLink, actions[0], replyToLink, actions[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Reply(outputText, &tele.SendOptions{
|
||||||
|
ParseMode: "Markdown",
|
||||||
|
})
|
||||||
|
}
|
42
plugin/torf/main.go
Normal file
42
plugin/torf/main.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package torf
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
tele "gopkg.in/telebot.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func randResponse(saidType int) string {
|
||||||
|
responsesMap := map[int][]string{
|
||||||
|
1: {"有", "没有"},
|
||||||
|
2: {"好", "不好"},
|
||||||
|
3: {"是", "不是"},
|
||||||
|
4: {"尊嘟", "假嘟"},
|
||||||
|
}
|
||||||
|
|
||||||
|
if responses, exists := responsesMap[saidType]; exists {
|
||||||
|
return responses[rand.Intn(len(responses))]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func Execute(c tele.Context) error {
|
||||||
|
inputText := c.Text()
|
||||||
|
var outputText string
|
||||||
|
|
||||||
|
if strings.Contains(inputText, "有没有") {
|
||||||
|
outputText = randResponse(1)
|
||||||
|
} else if strings.Contains(inputText, "好不好") {
|
||||||
|
outputText = randResponse(2)
|
||||||
|
} else if strings.Contains(inputText, "是不是") {
|
||||||
|
outputText = randResponse(3)
|
||||||
|
} else if strings.Contains(inputText, "尊嘟假嘟") {
|
||||||
|
outputText = randResponse(4)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Reply(outputText)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user