commit 14e8e7f6271d04561b24d464c1f559dfabc5a2f4 Author: 机器人总动员 <73592731+devourbots@users.noreply.github.com> Date: Wed May 5 10:59:30 2021 +0800 init diff --git a/config.py b/config.py new file mode 100644 index 0000000..f9ac699 --- /dev/null +++ b/config.py @@ -0,0 +1 @@ +TOKEN = "1749418611:AAGOV2XB5mkMXqX-J_wtNu7KkrkhO_Xylmg" diff --git a/main.py b/main.py new file mode 100644 index 0000000..0a228e0 --- /dev/null +++ b/main.py @@ -0,0 +1,31 @@ +from telegram.ext import Updater +from config import TOKEN +from telegram import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply +from telegram.ext import CommandHandler, MessageHandler, Filters, ConversationHandler, CallbackQueryHandler +import sqlite3 +from func import start, reserve, run, kill, status, update, get + + +updater = Updater(token=TOKEN, use_context=True) +dispatcher = updater.dispatcher + + +start_handler = CommandHandler('start', start) +reserve_handler = CommandHandler('reserve', reserve) +run_handler = CommandHandler('run', run) +kill_handler = CommandHandler('kill', kill) +update_handler = CommandHandler('update', update) +status_handler = CommandHandler('status', status) +get_handler = CommandHandler('get', get) + + +dispatcher.add_handler(start_handler) +dispatcher.add_handler(reserve_handler) +dispatcher.add_handler(run_handler) +dispatcher.add_handler(kill_handler) +dispatcher.add_handler(update_handler) +dispatcher.add_handler(status_handler) +dispatcher.add_handler(get_handler) + +updater.start_polling() +updater.idle() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..40434bf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,22 @@ +bcrypt==3.2.0 +beautifulsoup4==4.9.3 +bs4==0.0.1 +certifi==2020.4.5.2 +cffi==1.14.0 +chardet==3.0.4 +cryptography==2.9.2 +decorator==4.4.2 +future==0.18.2 +idna==2.9 +paramiko==2.7.2 +pycparser==2.20 +pycryptodomex==3.9.4 +PyNaCl==1.4.0 +pyOpenSSL==19.1.0 +python-alipay-sdk==2.0.1 +python-telegram-bot==12.7 +requests==2.23.0 +six==1.15.0 +soupsieve==2.1 +tornado==6.0.4 +urllib3==1.25.9 diff --git a/test/__pycache__/connector.cpython-37.pyc b/test/__pycache__/connector.cpython-37.pyc new file mode 100644 index 0000000..2e4ee2f Binary files /dev/null and b/test/__pycache__/connector.cpython-37.pyc differ diff --git a/test/connector.py b/test/connector.py new file mode 100644 index 0000000..7d49ae1 --- /dev/null +++ b/test/connector.py @@ -0,0 +1,21 @@ +import redis + +# 连接 redis +# 指定主机地址,port与服务器连接,redis默认数据库有16个,默认db是0 +# r = redis.Redis(host='127.0.0.1', port=6379, encoding='utf8', decode_responses=True) # password='**' +# print(r.get('foo')) +# r.set('foo', '[1,2,3]') +# print(r.get('foo')) +# print(r.keys()) +# r.delete('foo') +# print(r.keys()) + +pool = redis.ConnectionPool(host='127.0.0.1', port=6379, encoding='utf8', decode_responses=True) + + +# r = redis.Redis(connection_pool=pool) +# r.set('foo', 'Bar') +# print(r.get('foo')) + +def get_connection(): + return redis.StrictRedis(connection_pool=pool) diff --git a/test/jieba-test.py b/test/jieba-test.py new file mode 100644 index 0000000..240186a --- /dev/null +++ b/test/jieba-test.py @@ -0,0 +1,47 @@ +# encoding=utf-8 +import jieba +import jieba.posseg as pseg +import time # 引入time模块 + +import redis + +import connector +test_word = ''' +📜 ZUOLUOTV 例行群规广播 📜 +📅 2021年5月5日 +⏱ 截至今天08:00 本群共有11374位群友 +———————————— +⚖️ 自由并不意味着没有规则,群内稳定和持续的交流氛围,依靠的是大家对规则的尊重。 +———————————— +📖 ZUOLUOTV群管理规范 📖 +🈯 本群提倡一切事务合法合规操作 +🔞 不允许传播违法、黑灰产相关内容 + +1.必Ban:传播黑灰产,贩卖手机卡、银行卡、个人信息。 +2.必Ban:传播色情、暴力、低俗内容。 +3.必Ban:群发广告,ID或头像中带广告。 +4.别聊政治敏感话题,不鼓励聊翻墙、机场等话题,原因请看WHY。 +5.别搞人身攻击,别搞地域黑,别发布仇恨言论,别骚扰异性。 +6.别做伸手党,先看资料索引,学会谷歌搜索、善看群聊记录。 +7.不要用语音,不要连续刷屏,恶意刷屏将被Ban。 +8.鼓励原创分享,分享外链尽量是科技、数码、摄影、旅行主题。 +9.违反群规者,飞机场见✈,异议可私信管理员,精力时间有限,私聊不解答公开问题。 + +''' + +start_time = float(time.time()) +# words = pseg.cut("我爱北京天安门") # jieba默认模式 +jieba.enable_paddle() # 启动paddle模式。 0.40版之后开始支持,早期版本不支持 +words = pseg.cut(test_word, use_paddle=True) # paddle模式 +word_list = [] +for word, flag in words: + # print(word + "\t" + flag) + if flag in ["n", "nr", "nz", "PER", "f", "ns", "LOC", "s", "nt", "ORG", "nw"]: + word_list.append(word) + r = connector.get_connection() + r.set('foo', 'Bar') + print(r.get('foo')) +print(word_list) +stop_time = float(time.time()) +print(stop_time - start_time) + diff --git a/test/redishset.py b/test/redishset.py new file mode 100644 index 0000000..7c3145c --- /dev/null +++ b/test/redishset.py @@ -0,0 +1,10 @@ +import redis +pool = redis.ConnectionPool(host='127.0.0.1', port=6379, encoding='utf8', decode_responses=True, db=0) + +r = redis.StrictRedis(connection_pool=pool) + +# r.hset("user", "a", 1) +# r.hincrby('user', "a") +# r.hincrby('user', "b") +print(r.hget("user", "a")) +print(r.hget("user", "b")) diff --git a/test/rediswr.py b/test/rediswr.py new file mode 100644 index 0000000..5d0c79a --- /dev/null +++ b/test/rediswr.py @@ -0,0 +1,56 @@ +import redis +# encoding=utf-8 +import jieba +import wordcloud +import jieba.posseg as pseg +# 导入imageio库中的imread函数,并用这个函数读取本地图片,作为词云形状图片 +import imageio +import time # 引入time模块 + +pool = redis.ConnectionPool(host='127.0.0.1', port=6379, encoding='utf8', decode_responses=True, db=0) +start_time = float(time.time()) +r = redis.StrictRedis(connection_pool=pool) +with open("/root/Jupyter/143751443703354.txt", "r") as file: + i = 0 + for line in file.readlines(): + i += 1 + r.append("maozedong", line) + if i == 10: + break +# content = file.read() +# print(content) +print(r.get("maozedong")) + +mk = imageio.imread("/root/Jupyter/circle.png") +w = wordcloud.WordCloud(mask=mk) + +# 构建并配置词云对象w,注意要加scale参数,提高清晰度 +w = wordcloud.WordCloud(width=800, + height=800, + background_color='white', + font_path='/root/Jupyter/hanyiqihei.ttf', + mask=mk, + scale=5) + +# 对来自外部文件的文本进行中文分词,得到string + +jieba.enable_paddle() # 启动paddle模式。 0.40版之后开始支持,早期版本不支持 +words = pseg.cut(r.get("maozedong"), use_paddle=True) # paddle模式 +word_list = [] +for word, flag in words: + # print(word + "\t" + flag) + if flag in ["n", "nr", "nz", "PER", "f", "ns", "LOC", "s", "nt", "ORG", "nw"]: + word_list.append(word) + +string = " ".join(word_list) + + +# 将string变量传入w的generate()方法,给词云输入文字 +w.generate(string) + +# 将词云图片导出到当前文件夹 +w.to_file('maozedong-3.png') + + +stop_time = float(time.time()) +print(stop_time - start_time) diff --git a/test/timemap.py b/test/timemap.py new file mode 100644 index 0000000..1b95fee --- /dev/null +++ b/test/timemap.py @@ -0,0 +1,4 @@ +import time # 引入time模块 + +start_time = int(time.time()) +print("当前时间戳为:", int(ticks))