main #1
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,4 +2,4 @@
|
||||||
config.toml
|
config.toml
|
||||||
.vs
|
.vs
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
__pycache__
|
21
connect.py
21
connect.py
|
@ -15,10 +15,8 @@ from mcstatus import JavaServer
|
||||||
# 功能包引用处
|
# 功能包引用处
|
||||||
from module import hitokoto
|
from module import hitokoto
|
||||||
|
|
||||||
|
|
||||||
# 功能包结束引用
|
# 功能包结束引用
|
||||||
|
|
||||||
# 读取配置
|
|
||||||
def get_config() -> Tuple[str, str, int]:
|
def get_config() -> Tuple[str, str, int]:
|
||||||
with open('config.toml', 'r', encoding='utf-8') as f:
|
with open('config.toml', 'r', encoding='utf-8') as f:
|
||||||
config = qtoml.load(f)
|
config = qtoml.load(f)
|
||||||
|
@ -184,10 +182,8 @@ def safe_eval(code: str) -> str:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
# 获取到新的消息
|
|
||||||
@sio.on('addMessage')
|
@sio.on('addMessage')
|
||||||
async def add_message(data: Dict[str, Any]):
|
async def add_message(data: Dict[str, Any]):
|
||||||
|
|
||||||
print(f"{Fore.MAGENTA}add_message: {data}{Style.RESET_ALL}")
|
print(f"{Fore.MAGENTA}add_message: {data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
is_self = data['message']['senderId'] == SELF_ID
|
is_self = data['message']['senderId'] == SELF_ID
|
||||||
|
@ -198,13 +194,11 @@ async def add_message(data: Dict[str, Any]):
|
||||||
reply = ReplyMessage(id=data['message']['_id'])
|
reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
|
||||||
if not is_self:
|
if not is_self:
|
||||||
# /bot
|
|
||||||
if data.get('message').get('content') == '/bot':
|
if data.get('message').get('content') == '/bot':
|
||||||
message = Message(content='icalingua bot test',
|
message = Message(content='icalingua bot test',
|
||||||
room_id=data['roomId'])
|
room_id=data['roomId'])
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# !!status
|
|
||||||
elif content == '!!status':
|
elif content == '!!status':
|
||||||
server = JavaServer.lookup("192.168.1.6:25565")
|
server = JavaServer.lookup("192.168.1.6:25565")
|
||||||
status=server.status()
|
status=server.status()
|
||||||
|
@ -219,7 +213,6 @@ async def add_message(data: Dict[str, Any]):
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# !!players
|
|
||||||
elif content == '!!players':
|
elif content == '!!players':
|
||||||
server = JavaServer.lookup("192.168.1.6:25565")
|
server = JavaServer.lookup("192.168.1.6:25565")
|
||||||
query = server.query()
|
query = server.query()
|
||||||
|
@ -228,7 +221,6 @@ async def add_message(data: Dict[str, Any]):
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# !!hitokoto
|
|
||||||
elif content.startswith("!!hitokoto"):
|
elif content.startswith("!!hitokoto"):
|
||||||
|
|
||||||
ctypet = content[len("!!hitokoto "):]
|
ctypet = content[len("!!hitokoto "):]
|
||||||
|
@ -250,7 +242,6 @@ async def add_message(data: Dict[str, Any]):
|
||||||
|
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# 未知
|
|
||||||
elif data.get('message').get('content').startswith('=='):
|
elif data.get('message').get('content').startswith('=='):
|
||||||
|
|
||||||
evals: str = data.get('message').get('content')[2:]
|
evals: str = data.get('message').get('content')[2:]
|
||||||
|
@ -285,9 +276,16 @@ async def add_message(data: Dict[str, Any]):
|
||||||
|
|
||||||
await asyncio.sleep(random.random() * 2)
|
await asyncio.sleep(random.random() * 2)
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# !!jrrp
|
|
||||||
elif data['message']['content'] == '!!jrrp':
|
elif data['message']['content'] == '!!jrrp':
|
||||||
|
examSet = False
|
||||||
|
if examSet == True:
|
||||||
|
print('examSet参数被设定,替换人品值')
|
||||||
|
message = Message(content=f'{sender_name} 今日人品值为 100\n为了让你安心备考,加油考试,今天你的人品值是100!',
|
||||||
|
reply_to=reply,
|
||||||
|
room_id=room_id)
|
||||||
|
await asyncio.sleep(0.5)
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
else:
|
||||||
randomer = random.Random(f'{sender_id}-{data["message"]["date"]}-jrrp-v2')
|
randomer = random.Random(f'{sender_id}-{data["message"]["date"]}-jrrp-v2')
|
||||||
result = randomer.randint(0, 50) + randomer.randint(0, 50)
|
result = randomer.randint(0, 50) + randomer.randint(0, 50)
|
||||||
print(f'{sender_name} 今日人品值为 {result}')
|
print(f'{sender_name} 今日人品值为 {result}')
|
||||||
|
@ -296,7 +294,6 @@ async def add_message(data: Dict[str, Any]):
|
||||||
room_id=room_id)
|
room_id=room_id)
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
await sio.emit('sendMessage', message.to_json())
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
# 如果只包括一个或多个 6
|
# 如果只包括一个或多个 6
|
||||||
# elif data['message']['content'].replace(' ', '') in ('6', '666', '六', '3+3', '5+1', '4+2', '2+4', '1+5'):
|
# elif data['message']['content'].replace(' ', '') in ('6', '666', '六', '3+3', '5+1', '4+2', '2+4', '1+5'):
|
||||||
# reply = ReplyMessage(id=data['message']['_id'])
|
# reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import requests
|
import requests
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
def hitokoto(ctypet):
|
def hitokoto(ctypet):
|
||||||
|
|
||||||
result_type = None
|
result_type = None
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,17 +0,0 @@
|
||||||
import time
|
|
||||||
import random
|
|
||||||
import asyncio
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
from typing import Dict, List, Tuple, Any, Optional, Union, Literal
|
|
||||||
|
|
||||||
import qtoml
|
|
||||||
import socketio
|
|
||||||
from colorama import Fore, Style
|
|
||||||
from nacl.signing import SigningKey
|
|
||||||
from lib_not_dr.types import Options
|
|
||||||
from mcstatus import JavaServer
|
|
||||||
|
|
||||||
server = JavaServer.lookup("192.168.1.6:25565")
|
|
||||||
|
|
||||||
def mcstatus():
|
|
Loading…
Reference in New Issue
Block a user