-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7914f5
commit e9b824d
Showing
22 changed files
with
445 additions
and
7,250 deletions.
There are no files selected for viewing
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,36 @@ | ||
name: docker-telegram-bot | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: telegram/ | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- uses: actions/checkout@v2 | ||
- | ||
name: Copy Resource File | ||
run: cp ../xi.json . | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: neverbehave/xixi-haha-bot:latest |
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 |
---|---|---|
@@ -1 +1 @@ | ||
.DS_Store | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
import json | ||
|
||
with open('xi-v1.json') as f: | ||
data = json.load(f) | ||
|
||
sentences = [] | ||
|
||
# extend data | ||
# \r\r\n is replaced by hand | ||
# ((新)(.*)) for attr | ||
# (新华社记者)(.*摄) | ||
# for i in data: | ||
# li = i.split('\n') | ||
# for s in li: | ||
# s = s.strip() | ||
# if s is not "": | ||
# if s.startswith('(新') is False and s.startswith('(') is False and s.startswith('(2') is False and s.startswith('《 ') is False and s.startswith('>') is False: | ||
# sentences.append(s) | ||
|
||
for s in data: | ||
if s.startswith('(人') is False and s.startswith('(') is False and s.startswith('(2') is False and s.startswith('《 ') is False and s.startswith('(2') is False: | ||
sentences.append(s) | ||
else: | ||
print(s) | ||
|
||
# a = list(set(sentences)) | ||
|
||
with open('xi-v2.json', 'w') as outfile: | ||
json.dump(sentences, outfile, indent=2, ensure_ascii=False) |
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,31 @@ | ||
import json | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
|
||
li = [] | ||
sentences = [] | ||
|
||
# Get ALL Articles | ||
for i in range(1, 16): | ||
print(i) | ||
result = requests.get( | ||
"http://jhsjk.people.cn/result/{}?form=706&else=501".format(i)) | ||
soup = BeautifulSoup(result.content) | ||
arr = soup.find_all('ul', class_="p1_2")[0].find_all('a') | ||
for a in arr: | ||
li.append('http://jhsjk.people.cn/' + a['href']) | ||
|
||
print('start fetching pages') | ||
for addr in li: | ||
print(addr) | ||
result = requests.get(addr) | ||
soup = BeautifulSoup(result.content) | ||
arr = soup.find_all(class_="d2txt_con")[0].find_all('p') | ||
|
||
for i in arr: | ||
sentences.append(i.text.strip()) | ||
|
||
|
||
with open('xi.json', 'w') as outfile: | ||
json.dump(sentences, outfile, indent=2, ensure_ascii=False) |
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,3 @@ | ||
BOT_TOKEN= | ||
WEBHOOK_PATH=/secret-path | ||
WEBHOOK_PORT=5000 |
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,21 @@ | ||
FROM node:lts-alpine3.16 | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
ENV BOT_TOKEN= | ||
ENV WEBHOOK_PATH /secret-path | ||
ENV WEBHOOK_PORT 5000 | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
EXPOSE 5000 | ||
|
||
CMD [ "npm", "run", "start:webhook" ] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.