Skip to content

Commit

Permalink
Fix workflows, use os.environ for sendmsg.py, add debug stuff and kee…
Browse files Browse the repository at this point in the history
…p new room awake

gosh that was a lot of commit text
  • Loading branch information
PlaceReporter99 committed Apr 28, 2024
1 parent 8dff46c commit 9bfab2b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 78 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/chatupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.5.3
uses: actions/checkout@v4

- name: Install required packages
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Send Message
run: python3 sendmsg.py ${{ secrets.BOT_EMAIL }} ${{ secrets.BOT_PASSWORD }} ${{ github.event_name }} ${{ github.actor }}
run: python3 sendmsg.py
env:
email: ${{ secrets.BOT_EMAIL }}
password: ${{ secrets.BOT_PASSWORD }}
event: ${{ github.event_name }}
actor: ${{ github.actor }}
29 changes: 0 additions & 29 deletions .github/workflows/manual_test.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/tests.yml

This file was deleted.

11 changes: 6 additions & 5 deletions sendmsg.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import re
import sys
import os

import sechat

EMAIL = sys.argv[1]
PASSWORD = sys.argv[2]
EVENT_NAME = sys.argv[3]
EVENT_USER = sys.argv[4]
EMAIL = os.environ["username"]
PASSWORD = os.environ["password"]
EVENT_NAME = os.environ["event"]
EVENT_USER = os.environ["actor"]

cleaned = re.sub(r"\[.*\]", "", EVENT_USER)

bot = sechat.Bot()
bot.login(EMAIL, PASSWORD)
r = bot.joinRoom(147676)
r = bot.joinRoom(152883)


def indent(text):
Expand Down
15 changes: 12 additions & 3 deletions utilitybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
from firebase_admin import credentials
from firebase_admin import firestore

with open('database_auth.json') as f:
print(f.read())
cred = credentials.Certificate('database_auth.json')
print(cred)
f_init = firebase_admin.initialize_app(cred)
print(f_init)
db = firestore.client()
print(db)

# import streamlit as st

Expand Down Expand Up @@ -63,7 +68,8 @@ def remote(event):
def dataread(coll, user, key):
try:
return db.collection(coll).document(user).to_dict()[key]
except:
except BaseException as e:
print(e)
return None

def datawrite(coll, user, key, value):
Expand All @@ -74,6 +80,7 @@ def datatoggle(coll, user, key):

def tobool(val, truthy=["true", "1", "on", "y", "yes", "t", "i"], falsy=["false", "0", "off", "n", "no", "f", "o"], strfunc = (lambda x: str(x).lower())):
ch = strfunc(val)
print(ch)
if ch in truthy:
return True
elif ch in falsy:
Expand Down Expand Up @@ -364,9 +371,11 @@ def msg(event):
bot = sechat.Bot()
bot.login(os.environ["BOT_EMAIL"], os.environ["BOT_PASSWORD"])
def repeat():
[r, baso] = [bot.joinRoom(1), bot.joinRoom(146039)]
for room in [r, baso]:
import datetime
[r, baso, ubot] = map(bot.joinRoom, [1, 146039, 152883])
for room in [r, baso, ubot]:
onn(room)
ubot.send(f"Wake up, it's {str(datetime.datetime.now())}")
repeat()
app.run(host='0.0.0.0', port=5000)
try:
Expand Down

0 comments on commit 9bfab2b

Please sign in to comment.