This commit is contained in:
2025-04-23 08:10:40 +00:00
parent b774e0d04c
commit ad4ec4d3a9
13 changed files with 57 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -12,12 +12,12 @@ class Admin(Plugin):
super(Admin, self).deactivate()
@Plugin.command(admin=True)
def admin_reload_plugins(self, msg, args):
def admin_reload_plugins(self, room, event, args):
"""Reload plugins"""
self.plugin_manager.reload_plugins()
return "Plugins reloaded"
@Plugin.command(admin=True)
def admin_test(self, msg, args):
def admin_test(self, room, event, args):
"""Simple test"""
return "You are admin"

30
plugins/free_games.py Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
from plugins.plugin import Plugin
from bs4 import BeautifulSoup
import requests
class FreeGames(Plugin):
def activate(self):
super(FreeGames, self).activate()
def deactivate(self):
super(FreeGames, self).deactivate()
@Plugin.command()
def epic(self, room, event, args):
"""Display Epic free games => !epic"""
r=requests.get('https://feed.phenx.de/lootscraper_epic_game.xml')
soup = BeautifulSoup(r.content, 'xml')
c_list = soup.find_all('entry')
for c in c_list:
link = c.find('link').get('href')
title = c.find('title')
content = "{}\n".format(title.text)
content = "{}\n\n".format(link)
for li in c.find_all('li'):
content += "- {}\n".format(li.text)
room.send_text(content)

View File

@@ -25,7 +25,7 @@ class Help(Plugin):
reply = ['Usage:']
for command_name in command_names:
command = self.plugin_manager.commands[command_name]
if not self.plugin_manager.is_admin_command(command_name) or self.plugin_manager.is_sender_admin(msg):
if not self.plugin_manager.is_admin_command(command_name) or self.plugin_manager.is_sender_admin(event):
reply.append('{0}: {1}'.format(command_name, command['function'].__doc__ or 'N/A'))
room.send_text("\n".join(reply))
return True

View File

@@ -86,16 +86,7 @@ class PluginManager:
room.send_text(reply)
def is_sender_admin(self, event):
return False
"""Checks if author is admin"""
if message['type'] == 'groupchat':
# We don't know the jid. Either there's a problem or it's an anonymous room
if message['from'].full not in self.bot.presences:
return False
jid = self.bot.presences[message['from'].full]
else:
jid = message['from'].full.split('/')[0]
return jid in self.config.ADMINS
return event['sender'] in self.config.ADMINS
def is_admin_command(self, command):
return command in self.commands and self.commands[command]['options'].get('admin', False)