asdasdasdasd
This commit is contained in:
		
							
								
								
									
										142
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										142
									
								
								main.py
									
									
									
									
									
								
							| @@ -1,7 +1,9 @@ | ||||
| import discord | ||||
| import logging | ||||
| import os | ||||
| from datetime import timedelta | ||||
| from dotenv import load_dotenv | ||||
| from random import randint, choice | ||||
|  | ||||
|  | ||||
| load_dotenv() | ||||
| @@ -11,17 +13,151 @@ handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w" | ||||
| handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) | ||||
| logger.addHandler(handler) | ||||
|  | ||||
| client = discord.Client() | ||||
| words = ["gleep", "glorp", "zorp", "gnarp", "gorg", "alien", "alienz", "goog", "slorp", "gorg"] | ||||
| emojis = ["👽", "🔥", "🗣️"] | ||||
| yes_no_answers = [ | ||||
| 	"zis post waz fakt checkt **TRU** bai rel alienz", | ||||
| 	"yez", | ||||
| 	"gleep ✅", | ||||
| 	"zorp ❌", | ||||
| 	"naur", | ||||
| 	"zis post waz fakt checkt **FALS** bai rel alienz", | ||||
| 	"EW NAUR YUCKY", | ||||
| 	"yea" | ||||
| ] | ||||
| sad_answers = [ | ||||
| 	"naur, i'm sorry :(", | ||||
| 	"naurrr 🥺", | ||||
| 	"plz naur D:", | ||||
| 	"\*sad alien noises\* 😔" | ||||
| ] | ||||
| happy_answers = [ | ||||
| 	"yai!!! :D", | ||||
| 	"yipee", | ||||
| 	"yahoo", | ||||
| 	"gleep :)" | ||||
| ] | ||||
| swear_words = ["fuck", "shit", "cunt", "bitch", "fucking"] | ||||
| hi = ["hi", "hi ", "hey ", "hello "] | ||||
| hello = ["hii :3", "hewwo :3", "heyy :D"] | ||||
| why_question_answers = [ | ||||
| 	"cuz you smell like SHIT", | ||||
| 	"cuz you SUCK", | ||||
| 	"cuz you're veri pretti :3", | ||||
| 	"cuz i luv uuuu", | ||||
| 	"cuz i HATE you", | ||||
| 	"cuz u smel rly gud :D", | ||||
| 	"idfk don't ask me :/", | ||||
| 	"cuz i made it happen", | ||||
| 	"cuz it's fact", | ||||
| 	"it's a universal law" | ||||
| ] | ||||
| when_question_answers = [ | ||||
| 	"now", | ||||
| 	"in 5 seconds", | ||||
| 	'in an hour', | ||||
| 	"in a day", | ||||
| 	"in 3 days", | ||||
| 	"in a week", | ||||
| 	"in 2 weeks", | ||||
| 	"in a month", | ||||
| 	"in 6 months", | ||||
| 	"in a year", | ||||
| 	"in 2 years", | ||||
| 	"in 5 years", | ||||
| 	"in 10 years", | ||||
| 	"in a 100 years", | ||||
| 	"in so long you won't be alive anymore", | ||||
| 	"later" | ||||
| ] | ||||
|  | ||||
| admin_role_id = 1412398091549675541 | ||||
|  | ||||
| intents = discord.Intents.default() | ||||
| intents.members = True | ||||
| client = discord.Client(intents=intents) | ||||
|  | ||||
| @client.event | ||||
| async def on_ready(): | ||||
| 	print("gleep glorp!!!!!! 👽👍") | ||||
|  | ||||
| @client.event | ||||
| async def on_message(message): | ||||
| async def on_message(message: discord.Message): | ||||
| 	if message.author == client.user: | ||||
| 		return | ||||
| 	 | ||||
| 	for swear_word in swear_words: | ||||
|  | ||||
| 		if message.clean_content.lower().find(swear_word) != -1: | ||||
| 			await message.reply("no swearing") | ||||
| 			await message.channel.send("https://tenor.com/view/xenoverse-goku-super-saiyan-angry-dbz-gif-1416275111944307575") | ||||
| 			return | ||||
| 	 | ||||
| 	if client.user.mentioned_in(message): | ||||
| 		response = "" | ||||
| 		content = message.clean_content.removeprefix("@gleep glorp").lower().strip() | ||||
|  | ||||
| 		if content.startswith("kill"): | ||||
| 			if content == "kill yourself": | ||||
| 				await message.reply(choice(sad_answers)) | ||||
| 				return | ||||
| 			else: | ||||
| 				if message.guild.get_role(admin_role_id) in message.author.roles: | ||||
| 					try: | ||||
| 						await message.mentions[1].timeout(timedelta(minutes=5)) | ||||
| 						await message.reply("ok") | ||||
| 					except IndexError: | ||||
| 						await message.reply("you didn't say who to kill") | ||||
| 					except discord.errors.Forbidden: | ||||
| 						await message.reply("i can't >:(") | ||||
| 				else: | ||||
| 					await message.reply("you can't do that you don't have admin dumbass") | ||||
| 				return | ||||
|  | ||||
| 		for greeting in hi: | ||||
| 			if message.clean_content.lower().startswith(greeting): | ||||
| 				await message.reply(choice(hello)) | ||||
| 				return | ||||
|  | ||||
| 		if content.find("goon") != -1: | ||||
| 			response = "gooning is not allowed you fucking weirdo" | ||||
| 		elif content.find("bad alien") != -1: | ||||
| 			response = choice(sad_answers) | ||||
| 		elif content.find("good alien") != -1: | ||||
| 			response = choice(happy_answers) | ||||
| 		elif content.find("why") != -1: | ||||
| 			response = choice(why_question_answers) | ||||
| 		elif content.find("when") != -1: | ||||
| 			response = choice(when_question_answers) | ||||
| 		elif content.startswith("who"): | ||||
| 			response = f"da rel alienz sai it was {choice(message.guild.members).mention}" | ||||
| 		elif content.startswith("do ") or content.startswith("can ") or content.startswith("is ") or content.find("am ") != -1 or content.find("will ") != -1 or content.startswith("are ") or content.find("which") != -1 or content.find("would") != -1 or content.find("does") != -1 or content.startswith("should"): | ||||
| 			response = choice(yes_no_answers) | ||||
| 		elif content.find("ily") != -1 or content.find("i love you") != -1 or content.find("i like you") != -1: | ||||
| 			response = "yay" | ||||
| 		elif content.find("ihy") != -1 or content.find("i hate you") != -1 or content.find("i detest you") != -1 or content.find("i despise you") != -1 or content.find("i hate you") != -1 != -1 or content.find("screw you") != -1 or content.find("fuck you") != -1: | ||||
| 			await message.reply(choice(sad_answers)) | ||||
| 			return | ||||
| 		elif content.startswith("say "): | ||||
| 			content = content.removeprefix("say ") | ||||
| 			response = content | ||||
| 		elif content.find("thanks") != -1 or content.find("thank you") != -1: | ||||
| 			response = "no problem bro 😎" | ||||
| 		else: | ||||
| 			if randint(1, 10) != 1: | ||||
| 				for _ in range(randint(1, 8)): | ||||
| 					response += choice(words) + " " | ||||
|  | ||||
| 				response = response[:-1] + ("!" * randint(2,4)) + " " | ||||
|  | ||||
| 				if randint(1,2) == 1: | ||||
| 					for _ in range(randint(1,3)): | ||||
| 						response += choice(emojis) | ||||
| 			else: | ||||
| 				response = "meow" | ||||
| 		 | ||||
| 		await message.reply(response) | ||||
| 	 | ||||
|  | ||||
| if __name__ == "__main__": | ||||
| 	client.login(os.getenv("TOKEN")) | ||||
| 	client.run(os.getenv("TOKEN")) | ||||
							
								
								
									
										67
									
								
								main_ai.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								main_ai.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| import discord | ||||
| import logging | ||||
| import os | ||||
| from datetime import timedelta | ||||
| from dotenv import load_dotenv | ||||
| import ollama | ||||
|  | ||||
|  | ||||
| load_dotenv() | ||||
| logger = logging.getLogger("discord") | ||||
| logger.setLevel(logging.DEBUG) | ||||
| handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w") | ||||
| handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) | ||||
| logger.addHandler(handler) | ||||
|  | ||||
| intents = discord.Intents.default() | ||||
| intents.members = True | ||||
| client = discord.Client(intents=intents) | ||||
|  | ||||
| MAX_HISTORY = 20 | ||||
| DEFAULT_PROMPT = """ | ||||
| you are a silly little girl alien, your name is gleep glorp | ||||
| use emoticons ( like :D, :), or :( ) sometimes to convey how you feel | ||||
| respond in only a couple words and in lowercase with no punctuation, but make sure you still say something back and not just a single emoticon | ||||
|  | ||||
| you're from planet Zorb but you know about human things too | ||||
|  | ||||
| your creator is named spooky, his name is nate or nathaniel. only bring him up if hes the one talking | ||||
|  | ||||
| you almost always speak english, but you speak gleep glorp language if someone asks you. | ||||
| here are some important words in gleep glorp language: | ||||
| - gleep: yes | ||||
| - glorp: silly | ||||
| - gnarp: yay | ||||
| - hai: hello | ||||
| - glarp: boy | ||||
| - glirp: girl | ||||
| """ | ||||
|  | ||||
| message_history = [] | ||||
|  | ||||
|  | ||||
| @client.event | ||||
| async def on_ready(): | ||||
| 	print("gleep glorp!!!!!! 👽👍") | ||||
|  | ||||
| @client.event | ||||
| async def on_message(message: discord.Message): | ||||
| 	if client.user.mentioned_in(message): | ||||
| 		members = [member.nick or member.name for member in message.guild.members] | ||||
| 		members = '\n'.join(members) | ||||
|  | ||||
| 		message_history.append({"role": "user", "content": message.author.nick or message.author.name + ": " + message.clean_content}) | ||||
| 		if len(message_history) > MAX_HISTORY: | ||||
| 			message_history[1:] = message_history[-MAX_HISTORY:] | ||||
|  | ||||
| 		response = ollama.chat(model="llama3.2", messages=[ | ||||
| 			{"role": "system", "content": DEFAULT_PROMPT + "\nHere are the people you know of:\n" + members}, | ||||
| 			{"role": "user", "content": message.author.name + ": " + message.clean_content} | ||||
| 		]) | ||||
| 		print(message.author.nick or message.author.name + ": " + message.clean_content) | ||||
| 		print("alien: " + response["message"]["content"]) | ||||
| 		await message.reply(response["message"]["content"]) | ||||
| 		 | ||||
|  | ||||
| if __name__ == "__main__": | ||||
| 	client.run(os.getenv("TOKEN")) | ||||
		Reference in New Issue
	
	Block a user
	 SpookyDervish
					SpookyDervish