Add welcome file
This commit is contained in:
parent
9205af74b7
commit
d38c8c7b1c
|
@ -21,5 +21,6 @@ services:
|
||||||
- ${PWD}/config/:/bot/config
|
- ${PWD}/config/:/bot/config
|
||||||
- ${PWD}/credentials.json:/bot/credentials.json
|
- ${PWD}/credentials.json:/bot/credentials.json
|
||||||
- ${PWD}/token.pickle:/bot/token.pickle
|
- ${PWD}/token.pickle:/bot/token.pickle
|
||||||
|
- ${PWD}/welcome.md:/bot/welcome.md
|
||||||
|
|
||||||
stop_signal: SIGINT
|
stop_signal: SIGINT
|
||||||
|
|
|
@ -11,14 +11,13 @@ class MatrixModule(BotModule):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
room_id = os.getenv("WELCOME_ROOMID")
|
self.room_id = os.getenv("WELCOME_ROOMID")
|
||||||
self.room_id = room_id
|
|
||||||
self.last_welcome_room_user_count = 0
|
self.last_welcome_room_user_count = 0
|
||||||
self.last_welcome_room_users = []
|
self.last_welcome_room_users = []
|
||||||
|
|
||||||
# If the provided welcome message is a file path, read the file into
|
# If the provided welcome message is a file path, read the file into
|
||||||
# the welcome message. Otherwise, use the variable data as the message.
|
# 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:
|
with open(os.getenv("WELCOME_MESSAGE"), "r") as file:
|
||||||
self.welcome_message = file.read()
|
self.welcome_message = file.read()
|
||||||
else:
|
else:
|
||||||
|
@ -38,13 +37,13 @@ class MatrixModule(BotModule):
|
||||||
|
|
||||||
if pollcount != 1:
|
if pollcount != 1:
|
||||||
new_users = newcomer_room_user_delta.get("recently_added", [])
|
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:
|
len(newcomer_room_user_delta.get("recently_removed")) > 0:
|
||||||
for owner in bot.owners:
|
for owner in bot.owners:
|
||||||
await bot.send_msg(
|
await bot.send_msg(
|
||||||
owner,
|
owner,
|
||||||
"Welcome Bot",
|
"Welcome Bot",
|
||||||
"User {left} left the Newcomers channel".format(
|
"User {left} left the welcome channel".format(
|
||||||
left=newcomer_room_user_delta.get(
|
left=newcomer_room_user_delta.get(
|
||||||
"recently_removed")
|
"recently_removed")
|
||||||
)
|
)
|
||||||
|
@ -61,14 +60,15 @@ class MatrixModule(BotModule):
|
||||||
"Welcome",
|
"Welcome",
|
||||||
self.welcome_message
|
self.welcome_message
|
||||||
)
|
)
|
||||||
for owner in bot.owners:
|
if len(user_list) > 0:
|
||||||
await bot.send_msg(
|
for owner in bot.owners:
|
||||||
owner,
|
await bot.send_msg(
|
||||||
"Welcome Bot",
|
owner,
|
||||||
"Sent a welcome message to: {noobs}".format(
|
"Welcome Bot",
|
||||||
noobs=user_list
|
"Sent a welcome message to: {noobs}".format(
|
||||||
|
noobs=user_list
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def get_user_list_delta(
|
def get_user_list_delta(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -22,7 +22,7 @@ class MatrixModule(BotModule):
|
||||||
|
|
||||||
# If the provided welcome message is a file path, read the file into
|
# If the provided welcome message is a file path, read the file into
|
||||||
# the welcome message. Otherwise, use the variable data as the message.
|
# 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:
|
with open(os.getenv("WELCOME_MESSAGE"), "r") as file:
|
||||||
self.welcome_message = file.read()
|
self.welcome_message = file.read()
|
||||||
else:
|
else:
|
||||||
|
@ -51,14 +51,15 @@ class MatrixModule(BotModule):
|
||||||
"Welcome",
|
"Welcome",
|
||||||
self.welcome_message
|
self.welcome_message
|
||||||
)
|
)
|
||||||
for owner in bot.owners:
|
if len(user_list) > 0:
|
||||||
await bot.send_msg(
|
for owner in bot.owners:
|
||||||
owner,
|
await bot.send_msg(
|
||||||
"Welcome Bot",
|
owner,
|
||||||
"Sent a welcome message to: {new_users}".format(
|
"Welcome Bot",
|
||||||
new_users=user_list
|
"Sent a welcome message to: {new_users}".format(
|
||||||
|
new_users=user_list
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def get_user_list_delta(
|
def get_user_list_delta(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Welcome to the server.
|
Loading…
Reference in New Issue