]> git.armaanb.net Git - tall.bot.git/commitdiff
first commit
authorArmaan Bhojwani <code@armaanb.net>
Wed, 16 Dec 2020 00:31:58 +0000 (19:31 -0500)
committerArmaan Bhojwani <code@armaanb.net>
Wed, 16 Dec 2020 00:31:58 +0000 (19:31 -0500)
.build.yml [new file with mode: 0644]
.gitignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
LICENSE [new file with mode: 0644]
README.md [new file with mode: 0644]
requirements.txt [new file with mode: 0644]
tallbot.py [new file with mode: 0755]

diff --git a/.build.yml b/.build.yml
new file mode 100644 (file)
index 0000000..bc16a4b
--- /dev/null
@@ -0,0 +1,15 @@
+image: archlinux
+packages:
+  - docker
+sources:
+  - https://git.sr.ht/~armaan/tall.bot
+secrets:
+  - cfca6590-dec3-46f3-abf0-3bce5c907e4a
+tasks:
+  - build: |
+      cd tall.bot
+      docker build -t armaanb/tall.bot:latest
+      docker login
+      docker push
+artifacts:
+  - gen-shell/src/gen-shell
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..67e8ef5
--- /dev/null
@@ -0,0 +1 @@
+tall.bot
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..bb581a1
--- /dev/null
@@ -0,0 +1,8 @@
+FROM python:3.8
+
+WORKDIR /src
+COPY . .
+
+RUN pip install -r requirements.txt
+
+ENTRYPOINT python tallbot.py $TOKEN
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..086cc32
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,8 @@
+tall.bot - a simple Discord Wikipedia bot
+Copyright © 2020 Armaan Bhojwani <code@armaanb.net>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..d12e66f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# tall.bot
+A simple discord Wikipedia bot
+
+## License
+Copyright Armaan Bhojwani 2020, MIT license
diff --git a/requirements.txt b/requirements.txt
new file mode 100644 (file)
index 0000000..520252e
--- /dev/null
@@ -0,0 +1,14 @@
+aiohttp==3.6.3
+async-timeout==3.0.1
+attrs==20.3.0
+beautifulsoup4==4.9.3
+certifi==2020.12.5
+chardet==3.0.4
+discord.py==1.5.1
+idna==2.10
+multidict==4.7.6
+requests==2.25.0
+soupsieve==2.1
+urllib3==1.26.2
+wikipedia==1.4.0
+yarl==1.5.1
diff --git a/tallbot.py b/tallbot.py
new file mode 100755 (executable)
index 0000000..a888a4e
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+# tall.bot - a simple Discord Wikipedia bot
+# Armaan Bhojwani 2020
+
+import sys
+import wikipedia
+import discord
+
+keywords = ["what is", "What is", "what was", "What was", "what were",
+            "What were", "who is", "Who is", "who was", "Who was", 
+            "who were", "Who were", "who are", "Who are"]
+
+def wiki_sum(search, sen):
+    try:
+        output = "From Wikipedia: " + wikipedia.summary(search, sentences=sen)
+    except:
+        output = "There was an error"
+
+    return output
+
+def keyword_check(inp):
+    x = inp.split()
+    x = " ".join(x[:2])
+    if x in keywords:
+        return True
+    else:
+        return False
+
+class MyClient(discord.Client):
+    async def on_ready(self):
+        print('Logged in as', self.user)
+
+    async def on_message(self, message):
+        if message.author == self.user:
+            return
+
+        if keyword_check(message.content):
+            await message.channel.send(wiki_sum(message.content.split()[2:], 2))
+
+client = MyClient()
+client.run(sys.argv[1])