Discord 裡的FunGPT

各位早上好,那么這篇文章是关于 我最近測试的AI 所以我也想分享一下。

代码如下:

#import os
import time
from keep_alive import keep_alive
from discord.ext import commands
import random as r
#import discord

bot = commands.Bot(
    command_prefix="/",  
    case_insensitive=True 

)


@bot.event 
async def on_ready():  # When the bot is ready
    print("I'm in")
    print(bot.user)  

@bot.command()
async def say_hello(ctx):
  await ctx.send("Hello,I am chatGPT2.7,how can I help you.")

@bot.command()
async def introduce(ctx):
  await ctx.send("Hello , I am chatGPT2.7,who was made by W Tech Inc.")

@bot.command()
async def ask12(ctx,*,arg1):
  if arg1 == "Can you say chinese?":
    await ctx.send("Sorry,I cannot.")

@bot.command()
async def chat(ctx,*,arg1):
  if arg1 == "What can you do?":
    await ctx.send("Hello there,I know many about of things,but nowsaday, for my version,is not doing many things.")
  elif arg1 == "Can you code with me?":
    await ctx.send("Of course no,because of my commands code place haven't many things.")
  elif arg1 == "Can you write a story?":
    psg1 = """
    Man has bacon and eggs for breakfast’ is not a story idea that is going to have readers clawing for a copy of your book. It also is highly unlikely this would sustain an entire novel.
    """
    psg2 = """
    Exploring the rhythm of your writing consciously will help you to write better sentences. A book contains many sentences, so make yours easier and lovelier to read. Consciously crafted, creative prose makes a book better in any genre.
    """
    await ctx.send(psg1)
  elif arg1 == "What food do you recommand?":
    await ctx.send("I recommand you eat some meat.")
  elif arg1 == "What commands do you have?":
    await ctx.send("""
     I have:
     /chat <long argument> -- It can chat with me
     /ask12 <long argument> -- It only can ask me one question
     /say <argument> -- Anything do you want me to say
     /plus_math <arg1> <arg2> -- It can sum them.(Remember,the argument must be int.Otherwise, that will be error.)
    """)
  elif arg1 == "Can you write a sentence?" or arg1 == "你能寫一句句子嗎?":
    Sub = ["I","You","We","They","He","She","It"]
    Obj = ["me.","you.","us.","them.","him.","her.","it."]
    verb = ["eat","drink","fight","kill"]
    S = r.choice(Sub)
    V = r.choice(verb)
    O = r.choice(Obj)
    await ctx.send(f"{S} {V} {O}")
  elif arg1 == "hello" or arg1 == "hi":
    await ctx.send("Hello there,how cam I help you today?")
  elif arg1 == "Can you tell me a story?" or arg1 == "story,please?":
    t = ["Today,","Yestasday,","One aspon a time,"]
    Sub = ["I","We","You","They","He","She","It"]
    Obj = ["me","you","them","us","him","it"]
    verb = ["eat","drink","fight","see"]
    new_time = r.choice(t)
    new_Sub = r.choice(Sub)
    new_Obj = r.choice(Obj)
    new_verb = r.choice(verb)
    if new_time == "Yestasday," or new_time == "One aspon a time,":
      verb = ["ate","droink","fighted","saw"]
      new_verb = r.choice(verb)
      sentence = f"{new_time} {new_Sub} {new_verb} {new_Obj},and {new_Sub} {new_verb} {new_Obj}."
      await ctx.send(sentence)
  
  else:
    await ctx.send("Sorry,lack of commands.")


@bot.command(pass_context = True)
async def say(ctx,*,arg1):
  await ctx.send(arg1)

@bot.command()
async def plus_math(ctx,arg1,arg2):
  try:
     num1 = int(arg1)
     num2 = int(arg2)
     ans = num1 + num2
     await ctx.send(f"The ans is {ans}")
  except ValueError:
    await ctx.send("你輸入的參數類型不正確。")

@bot.command()
async def build_API(ctx):
  prefix = "X29saQoaoX2CvsiOkwoXcvWeosoks"
  numbers = "1234567890"
  suffix = "sdOkkOjwjkp0Hjkaokkwqki"
  api_key = prefix
  for i in range(32):
    api_key += r.choice(numbers)
  api_key += suffix
  await ctx.send(api_key)

    #可以加指令或其他东西 

    #指令的话首先加 @bot.commands() 然后

    #async def 指令名(ctx,arg): 就行啦

keep_alive()

bot.run("TOKEN")

 

这只bot 好笑的地方 在于它在random 字词的时侯 有时侯有点搞笑

 

最后,我也希望大家可以评论,我也会改善,谢谢

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值