From 6ba8a420895762e8ddfed91b5ca8ac7a3ab405b6 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 11 Mar 2022 09:20:07 -0800 Subject: [PATCH] Adding the wolfram api key as an env var --- README.md | 0 app/.syncthing.questions.py.tmp | 28 ++++++++++ app/bot.py | 1 - app/questions.py | 3 +- helm/.syncthing.values.yaml.tmp | 95 +++++++++++++++++++++++++++++++++ helm/values.yaml | 3 +- 6 files changed, 127 insertions(+), 3 deletions(-) mode change 100755 => 100644 README.md create mode 100644 app/.syncthing.questions.py.tmp create mode 100644 helm/.syncthing.values.yaml.tmp diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/app/.syncthing.questions.py.tmp b/app/.syncthing.questions.py.tmp new file mode 100644 index 00000000..0a301bbd --- /dev/null +++ b/app/.syncthing.questions.py.tmp @@ -0,0 +1,28 @@ +import os +import wikipedia +import wolframalpha + +import help_methods + + +def answer_question(message): + """ + answer_question(question) + + Submits a request to the wolfram API and returns the response + If no answer is found, tries wikipedia. If that fails, apologizes + """ + + if len(message.split()) > 1: + client = wolframalpha.Client(os.getenv("wolfram_token")) + question = " ".join(message.split()[1:]) + try: + res = client.query(question) + return next(res.results).text + except Exception: + try: + return wikipedia.summary(question, sentences=5) + except Exception: + return "Sorry, I'm unable to answer that" + + return help_methods.get_help_message("message") diff --git a/app/bot.py b/app/bot.py index cb503491..654d7a0a 100755 --- a/app/bot.py +++ b/app/bot.py @@ -591,7 +591,6 @@ async def tts(ctx): @bot.command(name="issue") async def issue(ctx): - import gitlab await ctx.send(gitlab.parse_message(ctx.message)) diff --git a/app/questions.py b/app/questions.py index e1b6a952..0a301bbd 100755 --- a/app/questions.py +++ b/app/questions.py @@ -1,3 +1,4 @@ +import os import wikipedia import wolframalpha @@ -13,7 +14,7 @@ def answer_question(message): """ if len(message.split()) > 1: - client = wolframalpha.Client("2LU2Y7-YJQTA7TL8E") + client = wolframalpha.Client(os.getenv("wolfram_token")) question = " ".join(message.split()[1:]) try: res = client.query(question) diff --git a/helm/.syncthing.values.yaml.tmp b/helm/.syncthing.values.yaml.tmp new file mode 100644 index 00000000..883ca3de --- /dev/null +++ b/helm/.syncthing.values.yaml.tmp @@ -0,0 +1,95 @@ +# Default values for dragon-bot. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ldooks/dragon-bot + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "122" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +volumes: + name: dale-pics + type: nfs + server: 192.168.1.119 + path: /volume1/nas/docker_storage/default-syncthing-claim-pvc-24ed3294-4330-466f-bc4b-70b1fe192d5f/syncthing-configs/Dropbox Mirror/Photos/dale + mountPath: /tmp/dale + +env: + token: discord_token + ffxiv_token: ffxiv_token + gitlab_token: gitlab_token + wolfram_token: wolfram_token diff --git a/helm/values.yaml b/helm/values.yaml index f4c41820..883ca3de 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -8,7 +8,7 @@ image: repository: ldooks/dragon-bot pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "121" + tag: "122" imagePullSecrets: [] nameOverride: "" @@ -92,3 +92,4 @@ env: token: discord_token ffxiv_token: ffxiv_token gitlab_token: gitlab_token + wolfram_token: wolfram_token