Update plugins, refactor proxy plugin, yt preview now gets lyrics
This commit is contained in:
@@ -50,38 +50,53 @@ async def handle_command(room, message, bot, prefix, config):
|
||||
Args:
|
||||
room (Room): The Matrix room where the command was invoked.
|
||||
message (RoomMessage): The message object containing the command.
|
||||
bot (Bot): The bot instance.
|
||||
prefix (str): The bot command prefix.
|
||||
config (FunguyConfig): The bot configuration instance.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
# Check if the message matches the command pattern and is not from this bot
|
||||
match = botlib.MessageMatch(room, message, bot, prefix)
|
||||
if match.is_not_from_this_bot() and match.prefix() and match.command("isup"):
|
||||
# Log that the !isup command has been received
|
||||
logging.info("Received !isup command")
|
||||
args = match.args()
|
||||
# Check if the command has exactly one argument
|
||||
if len(args) != 1:
|
||||
# If the command does not have exactly one argument, send usage message
|
||||
await bot.api.send_markdown_message(room.room_id, "Usage: !isup <ipv4/ipv6/domain>")
|
||||
logging.info("Sent usage message to the room")
|
||||
return
|
||||
|
||||
target = args[0]
|
||||
|
||||
# DNS resolution
|
||||
# Perform DNS resolution
|
||||
try:
|
||||
ip_address = socket.gethostbyname(target)
|
||||
# Log successful DNS resolution
|
||||
logging.info(f"DNS resolution successful for {target}: {ip_address}")
|
||||
# Send DNS resolution success message
|
||||
await bot.api.send_markdown_message(room.room_id, f"✅ DNS resolution successful for **{target}**: **{ip_address}** (A record)")
|
||||
except socket.gaierror:
|
||||
# Log DNS resolution failure
|
||||
logging.info(f"DNS resolution failed for {target}")
|
||||
# Send DNS resolution failure message
|
||||
await bot.api.send_markdown_message(room.room_id, f"❌ DNS resolution failed for **{target}**")
|
||||
return
|
||||
|
||||
# Check HTTP/HTTPS services
|
||||
if await check_http(target):
|
||||
# If HTTP service is up, send HTTP service up message
|
||||
await bot.api.send_markdown_message(room.room_id, f"🖧 **{target}** HTTP service is up")
|
||||
logging.info(f"{target} HTTP service is up")
|
||||
elif await check_https(target):
|
||||
# If HTTPS service is up, send HTTPS service up message
|
||||
await bot.api.send_markdown_message(room.room_id, f"🖧 **{target}** HTTPS service is up")
|
||||
logging.info(f"{target} HTTPS service is up")
|
||||
else:
|
||||
# If both HTTP and HTTPS services are down, send service down message
|
||||
await bot.api.send_markdown_message(room.room_id, f"😕 **{target}** HTTP/HTTPS services are down")
|
||||
logging.info(f"{target} HTTP/HTTPS services are down")
|
||||
|
||||
|
Reference in New Issue
Block a user