robinroy03 commited on
Commit
1b31a45
β€’
1 Parent(s): dc31c0e

First commit

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. app.py +48 -0
  3. requirements.txt +18 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ venv/
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import discord
2
+
3
+ import os
4
+ import requests
5
+
6
+ intents = discord.Intents.default()
7
+ intents.message_content = True
8
+ bot = discord.Bot(intents = intents)
9
+ token = os.environ.get('TOKEN_DISCORD')
10
+
11
+ class Like_Dislike(discord.ui.View):
12
+ @discord.ui.button(style=discord.ButtonStyle.primary, emoji="πŸ‘")
13
+ async def like_button(self, button, interaction):
14
+ await interaction.response.send_message("You liked the response")
15
+
16
+ @discord.ui.button(style=discord.ButtonStyle.primary, emoji="πŸ‘Ž")
17
+ async def dislike_button(self, button, interaction):
18
+ await interaction.response.send_message("You disliked the response")
19
+
20
+ @bot.event
21
+ async def on_ready():
22
+ print(f"{bot.user} is ready and online!")
23
+
24
+ @bot.slash_command(name="help", description="list of commands and other info.")
25
+ async def help(ctx: discord.ApplicationContext):
26
+ await ctx.respond("Hello! FURY Bot responds to all your messages\
27
+ \n1)Inside Forum channel and\
28
+ \n2)Those that tag the bot.")
29
+
30
+ @bot.event
31
+ async def on_message(message):
32
+ url = 'http://127.0.0.1:8000/completion'
33
+ obj = {'user': message.author.id,
34
+ 'text': message.content.replace("<@1243428204124045385>", "")}
35
+
36
+ if (message.author != bot.user) and (bot.user.mentioned_in(message)):
37
+ await message.reply(content="Your message was received, it'll take around 10 seconds for FURY to process an answer.")
38
+
39
+ try:
40
+ return_obj = requests.post(url, json=obj)
41
+ print(return_obj.text)
42
+ await message.reply(content=return_obj.text, view=Like_Dislike())
43
+ except requests.exceptions.RequestException as e:
44
+ print(e)
45
+ await message.reply(content="Sorry something internally went wrong. Retry again.")
46
+
47
+
48
+ bot.run(token)
requirements.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiodns==3.2.0
2
+ aiohttp==3.9.5
3
+ aiosignal==1.3.1
4
+ attrs==23.2.0
5
+ Brotli==1.1.0
6
+ certifi==2024.6.2
7
+ cffi==1.16.0
8
+ charset-normalizer==3.3.2
9
+ frozenlist==1.4.1
10
+ idna==3.7
11
+ msgspec==0.18.6
12
+ multidict==6.0.5
13
+ py-cord==2.5.0
14
+ pycares==4.4.0
15
+ pycparser==2.22
16
+ requests==2.32.3
17
+ urllib3==2.2.1
18
+ yarl==1.9.4