update
This commit is contained in:
BIN
plugins/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/admin.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/free_games.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/free_games.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/help.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/help.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/plugin.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/plugin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/plugin_manager.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/plugin_manager.cpython-310.pyc
Normal file
Binary file not shown.
BIN
plugins/__pycache__/say.cpython-310.pyc
Normal file
BIN
plugins/__pycache__/say.cpython-310.pyc
Normal file
Binary file not shown.
@@ -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
30
plugins/free_games.py
Normal 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)
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user