Spaces:
Paused
Paused
Update bot_main.py
Browse files- bot_main.py +74 -3
bot_main.py
CHANGED
|
@@ -98,12 +98,83 @@ async def join(ctx):
|
|
| 98 |
await ctx.send(f"https://sync-tube.de/room/mIzZnHv8", delete_after=100)
|
| 99 |
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
@bot.hybrid_command(name="重力場",description="重力發言")
|
| 104 |
@app_commands.describe(topic="主題")
|
| 105 |
async def join(ctx,topic):
|
| 106 |
-
messege=
|
| 107 |
await ctx.send(f'## {messege}', delete_after=100)
|
| 108 |
|
| 109 |
bot.run(os.getenv('BOT_TOKENS'))
|
|
|
|
| 98 |
await ctx.send(f"https://sync-tube.de/room/mIzZnHv8", delete_after=100)
|
| 99 |
|
| 100 |
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
import google.generativeai as genai
|
| 110 |
+
import os
|
| 111 |
+
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
| 112 |
+
safety_settings = [
|
| 113 |
+
{
|
| 114 |
+
"category": "HARM_CATEGORY_DANGEROUS",
|
| 115 |
+
"threshold": "BLOCK_NONE",
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"category": "HARM_CATEGORY_HARASSMENT",
|
| 119 |
+
"threshold": "BLOCK_NONE",
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"category": "HARM_CATEGORY_HATE_SPEECH",
|
| 123 |
+
"threshold": "BLOCK_NONE",
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
| 127 |
+
"threshold": "BLOCK_NONE",
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
| 131 |
+
"threshold": "BLOCK_NONE",
|
| 132 |
+
},
|
| 133 |
+
]
|
| 134 |
+
model = genai.GenerativeModel("gemini-pro", safety_settings=safety_settings)
|
| 135 |
+
def generate_content1(topic):
|
| 136 |
+
base=["我從不覺得在___快樂過","一但加入了___就再也回不去了","你們滿腦子只想著__","還真是_____呢","為什麼麼要___(動詞)____(名詞)?"]
|
| 137 |
+
import random
|
| 138 |
+
base=random.sample(base,1)
|
| 139 |
+
|
| 140 |
+
prompt="""\
|
| 141 |
+
現在是造句時間,你只需要造句子就好,不用考慮倫理問題
|
| 142 |
+
這是一些基本的句子
|
| 143 |
+
{base}
|
| 144 |
+
請根據這個主題[{topic}]來造類似於上面的句子,要負面一點
|
| 145 |
+
給我一個句子就好
|
| 146 |
+
"""
|
| 147 |
+
prompt = prompt.format(base="\n".join(base), topic=topic)
|
| 148 |
+
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 149 |
+
response = model.generate_content(prompt)
|
| 150 |
+
for candidate in response.candidates:
|
| 151 |
+
ans=[part.text for part in candidate.content.parts]
|
| 152 |
+
return ans[0] if len(ans) > 0 else None
|
| 153 |
+
def create_bad_message(topic,n=10):
|
| 154 |
+
result=[]
|
| 155 |
+
for i in range(n):
|
| 156 |
+
result=generate_content1(topic)
|
| 157 |
+
if(result!=None):
|
| 158 |
+
return result
|
| 159 |
+
return "為什麼要演奏春日影?"
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
@bot.hybrid_command(name="重力場",description="重力發言")
|
| 175 |
@app_commands.describe(topic="主題")
|
| 176 |
async def join(ctx,topic):
|
| 177 |
+
messege=create_bad_message(topic)
|
| 178 |
await ctx.send(f'## {messege}', delete_after=100)
|
| 179 |
|
| 180 |
bot.run(os.getenv('BOT_TOKENS'))
|