fix: persistent settings for pollservices
pollservices didn't return the settings dictionary and the call to super was missing.
This commit is contained in:
parent
f8825a0582
commit
267b4241f8
9
bot.py
9
bot.py
|
@ -137,8 +137,8 @@ class Bot:
|
|||
traceback.print_exc(file=sys.stderr)
|
||||
else:
|
||||
print(f"Unknown command: {command}")
|
||||
await self.send_text(room, f"Sorry. I don't know what to do. Execute !help to get a list of available commands.")
|
||||
|
||||
await self.send_text(room,
|
||||
f"Sorry. I don't know what to do. Execute !help to get a list of available commands.")
|
||||
|
||||
async def invite_cb(self, room, event):
|
||||
room: MatrixRoom
|
||||
|
@ -155,7 +155,8 @@ class Bot:
|
|||
print(f"joining room '{room.display_name}'({room.room_id}) invited by '{event.sender}'")
|
||||
break
|
||||
else:
|
||||
print(f'Received invite event, but not joining as sender is not owner or bot not configured to join on invite. {event}')
|
||||
print(
|
||||
f'Received invite event, but not joining as sender is not owner or bot not configured to join on invite. {event}')
|
||||
|
||||
def load_module(self, modulename):
|
||||
try:
|
||||
|
@ -256,7 +257,6 @@ class Bot:
|
|||
print("The environment variables MATRIX_SERVER, MATRIX_USER and BOT_OWNERS are mandatory")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def start(self):
|
||||
self.load_settings(self.get_account_data())
|
||||
enabled_modules = [module for module_name, module in self.modules.items() if module.enabled]
|
||||
|
@ -330,6 +330,7 @@ class Bot:
|
|||
else:
|
||||
await self.client.client_session.close()
|
||||
|
||||
|
||||
bot = Bot()
|
||||
bot.init()
|
||||
try:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from abc import ABC, abstractmethod
|
||||
|
||||
from nio import RoomMessageText, MatrixRoom
|
||||
|
||||
|
||||
|
|
|
@ -94,22 +94,23 @@ class PollingService(BotModule):
|
|||
bot.must_be_admin(room, event)
|
||||
|
||||
account = args[2]
|
||||
print(
|
||||
f'Removing {self.service_name} account {account} from room id {room.room_id}')
|
||||
print(f'Removing {self.service_name} account {account} from room id {room.room_id}')
|
||||
|
||||
if self.account_rooms.get(room.room_id):
|
||||
self.account_rooms[room.room_id].remove(account)
|
||||
|
||||
print(
|
||||
f'{self.service_name} accounts now for this room {self.account_rooms.get(room.room_id)}')
|
||||
print(f'{self.service_name} accounts now for this room {self.account_rooms.get(room.room_id)}')
|
||||
|
||||
bot.save_settings()
|
||||
await bot.send_text(room, f'Removed {self.service_name} account from this room')
|
||||
|
||||
def get_settings(self):
|
||||
return {'account_rooms': self.account_rooms}
|
||||
data = super().get_settings()
|
||||
data['account_rooms'] = self.account_rooms
|
||||
return data
|
||||
|
||||
def set_settings(self, data):
|
||||
super().set_settings(data)
|
||||
if data.get('account_rooms'):
|
||||
self.account_rooms = data['account_rooms']
|
||||
|
||||
|
|
|
@ -165,7 +165,3 @@ class MatrixModule(BotModule):
|
|||
|
||||
def help(self):
|
||||
return "If I see a url in a message I will try to get the title from the page and spit it out"
|
||||
|
||||
def dump(self, obj):
|
||||
for attr in dir(obj):
|
||||
print("obj.%s = %r" % (attr, getattr(obj, attr)))
|
Loading…
Reference in New Issue