Add welcome file

This commit is contained in:
Jackson Egan 2020-09-10 23:30:16 -04:00
parent 9205af74b7
commit d38c8c7b1c
4 changed files with 23 additions and 20 deletions

View File

@ -21,5 +21,6 @@ services:
- ${PWD}/config/:/bot/config
- ${PWD}/credentials.json:/bot/credentials.json
- ${PWD}/token.pickle:/bot/token.pickle
- ${PWD}/welcome.md:/bot/welcome.md
stop_signal: SIGINT

View File

@ -11,14 +11,13 @@ class MatrixModule(BotModule):
def __init__(self, name):
super().__init__(name)
room_id = os.getenv("WELCOME_ROOMID")
self.room_id = room_id
self.room_id = os.getenv("WELCOME_ROOMID")
self.last_welcome_room_user_count = 0
self.last_welcome_room_users = []
# If the provided welcome message is a file path, read the file into
# the welcome message. Otherwise, use the variable data as the message.
if os.path.isFile(os.getenv("WELCOME_MESSAGE")):
if os.path.isfile(os.getenv("WELCOME_MESSAGE")):
with open(os.getenv("WELCOME_MESSAGE"), "r") as file:
self.welcome_message = file.read()
else:
@ -38,13 +37,13 @@ class MatrixModule(BotModule):
if pollcount != 1:
new_users = newcomer_room_user_delta.get("recently_added", [])
if os.getenv("WELCOME_ROOM_NOTIFY_DEPARTURE") and \
if os.getenv("WELCOME_ROOM_NOTIFY_DEPARTURE", 0) and \
len(newcomer_room_user_delta.get("recently_removed")) > 0:
for owner in bot.owners:
await bot.send_msg(
owner,
"Welcome Bot",
"User {left} left the Newcomers channel".format(
"User {left} left the welcome channel".format(
left=newcomer_room_user_delta.get(
"recently_removed")
)
@ -61,6 +60,7 @@ class MatrixModule(BotModule):
"Welcome",
self.welcome_message
)
if len(user_list) > 0:
for owner in bot.owners:
await bot.send_msg(
owner,

View File

@ -22,7 +22,7 @@ class MatrixModule(BotModule):
# If the provided welcome message is a file path, read the file into
# the welcome message. Otherwise, use the variable data as the message.
if os.path.isFile(os.getenv("WELCOME_MESSAGE")):
if os.path.isfile(os.getenv("WELCOME_MESSAGE")):
with open(os.getenv("WELCOME_MESSAGE"), "r") as file:
self.welcome_message = file.read()
else:
@ -51,6 +51,7 @@ class MatrixModule(BotModule):
"Welcome",
self.welcome_message
)
if len(user_list) > 0:
for owner in bot.owners:
await bot.send_msg(
owner,

1
welcome.md Normal file
View File

@ -0,0 +1 @@
Welcome to the server.