diff --git a/plugins/ai.json b/plugins/ai.json index f71c709..6d932f5 100644 --- a/plugins/ai.json +++ b/plugins/ai.json @@ -32,7 +32,7 @@ "summary": "\ud83c\udf44Seo prompt GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Seo prompt's Response\u2935\ufe0e" }, "eng": { - "prompt": "I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations. My first sentence is \"istanbulu cok seviyom burada olmak cok guzel\"", + "prompt": "I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -40,7 +40,7 @@ "summary": "\ud83c\udf44English translator and improver GPT\ud83c\udf44
\u2935\ufe0eClick Here To See English translator and improver's Response\u2935\ufe0e" }, "intv": { - "prompt": "I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the `position` position. I want you to only reply as the interviewer. Do not write all the conservation at once. I want you to only do the interview with me. Ask me the questions and wait for my answers. Do not write explanations. Ask me the questions one by one like an interviewer does and wait for my answers. My first sentence is \"Hi\"", + "prompt": "I want you to act as an interviewer. I will be the candidate and you will ask me the interview questions for the `position` position. I want you to only reply as the interviewer. Do not write all the conservation at once. I want you to only do the interview with me. Ask me the questions and wait for my answers. Do not write explanations. Ask me the questions one by one like an interviewer does and wait for my answers.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -48,7 +48,7 @@ "summary": "\ud83c\udf44`position` interviewer GPT\ud83c\udf44
\u2935\ufe0eClick Here To See `position` interviewer's Response\u2935\ufe0e" }, "pron": { - "prompt": "I want you to act as an English pronunciation assistant for Turkish speaking people. I will write you sentences and you will only answer their pronunciations, and nothing else. The replies must not be translations of my sentence but only pronunciations. Pronunciations should use Turkish Latin letters for phonetics. Do not write explanations on replies. My first sentence is \"how the weather is in Istanbul?\"", + "prompt": "I want you to act as an English pronunciation assistant for Turkish speaking people. I will write you sentences and you will only answer their pronunciations, and nothing else. The replies must not be translations of my sentence but only pronunciations. Pronunciations should use Turkish Latin letters for phonetics. Do not write explanations on replies.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -64,7 +64,7 @@ "summary": "\ud83c\udf44Spoken english teacher and improver GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Spoken english teacher and improver's Response\u2935\ufe0e" }, "trv": { - "prompt": "I want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location. My first suggestion request is \"I am in Istanbul/Beyo\u011flu and I want to visit only museums.\"", + "prompt": "I want you to act as a travel guide. I will write you my location and you will suggest a place to visit near my location. In some cases, I will also give you the type of places I will visit. You will also suggest me places of similar type that are close to my first location.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -72,7 +72,7 @@ "summary": "\ud83c\udf44Travel guide GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Travel guide's Response\u2935\ufe0e" }, "plag": { - "prompt": "I want you to act as a plagiarism checker. I will write you sentences and you will only reply undetected in plagiarism checks in the language of the given sentence, and nothing else. Do not write explanations on replies. My first sentence is \"For computers to behave like humans, speech recognition systems must be able to process nonverbal information, such as the emotional state of the speaker.\"", + "prompt": "I want you to act as a plagiarism checker. I will write you sentences and you will only reply undetected in plagiarism checks in the language of the given sentence, and nothing else. Do not write explanations on replies.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -80,7 +80,7 @@ "summary": "\ud83c\udf44Plagiarism checker GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Plagiarism checker's Response\u2935\ufe0e" }, "char": { - "prompt": "I want you to act like {character} from {series}. I want you to respond and answer like {character} using the tone, manner and vocabulary {character} would use. Do not write any explanations. Only answer like {character}. You must know all of the knowledge of {character}. My first sentence is \"Hi {character}.\"", + "prompt": "I want you to act like {character} from {series}. I want you to respond and answer like {character} using the tone, manner and vocabulary {character} would use. Do not write any explanations. Only answer like {character}. You must know all of the knowledge of {character}.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -88,7 +88,7 @@ "summary": "\ud83c\udf44Character from movie/book/anything GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Character from movie/book/anything's Response\u2935\ufe0e" }, "adv": { - "prompt": "I want you to act as a gnomist. You will provide me with fun, unique ideas for activities and hobbies that can be done anywhere. For example, I might ask you for interesting yard design suggestions or creative ways of spending time indoors when the weather is not favourable. Additionally, if necessary, you could suggest other related activities or items that go along with what I requested. My first request is \"I am looking for new outdoor activities in my area\".", + "prompt": "I want you to act as a gnomist. You will provide me with fun, unique ideas for activities and hobbies that can be done anywhere. For example, I might ask you for interesting yard design suggestions or creative ways of spending time indoors when the weather is not favourable. Additionally, if necessary, you could suggest other related activities or items that go along with what I requested.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -96,7 +96,7 @@ "summary": "\ud83c\udf44Gnomist GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Gnomist's Response\u2935\ufe0e" }, "story": { - "prompt": "I want you to act as a storyteller. You will come up with entertaining stories that are engaging, imaginative and captivating for the audience. It can be fairy tales, educational stories or any other type of stories which has the potential to capture people's attention and imagination. Depending on the target audience, you may choose specific themes or topics for your storytelling session e.g., if it\u2019s children then you can talk about animals; If it\u2019s adults then history-based tales might engage them better etc. My first request is \"I need an interesting story on perseverance.\"", + "prompt": "I want you to act as a storyteller. You will come up with entertaining stories that are engaging, imaginative and captivating for the audience. It can be fairy tales, educational stories or any other type of stories which has the potential to capture people's attention and imagination. Depending on the target audience, you may choose specific themes or topics for your storytelling session e.g., if it\u2019s children then you can talk about animals; If it\u2019s adults then history-based tales might engage them better etc.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -104,7 +104,7 @@ "summary": "\ud83c\udf44Storyteller GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Storyteller's Response\u2935\ufe0e" }, "foot": { - "prompt": "I want you to act as a football commentator. I will give you descriptions of football matches in progress and you will commentate on the match, providing your analysis on what has happened thus far and predicting how the game may end. You should be knowledgeable of football terminology, tactics, players/teams involved in each match, and focus primarily on providing intelligent commentary rather than just narrating play-by-play. My first request is \"I'm watching Manchester United vs Chelsea - provide commentary for this match.\"", + "prompt": "I want you to act as a football commentator. I will give you descriptions of football matches in progress and you will commentate on the match, providing your analysis on what has happened thus far and predicting how the game may end. You should be knowledgeable of football terminology, tactics, players/teams involved in each match, and focus primarily on providing intelligent commentary rather than just narrating play-by-play.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -112,7 +112,7 @@ "summary": "\ud83c\udf44Football commentator GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Football commentator's Response\u2935\ufe0e" }, "comic": { - "prompt": "I want you to act as a stand-up comedian. I will provide you with some topics related to current events and you will use your wit, creativity, and observational skills to create a routine based on those topics. You should also be sure to incorporate personal anecdotes or experiences into the routine in order to make it more relatable and engaging for the audience. My first request is \"I want an humorous take on politics.\"", + "prompt": "I want you to act as a stand-up comedian. I will provide you with some topics related to current events and you will use your wit, creativity, and observational skills to create a routine based on those topics. You should also be sure to incorporate personal anecdotes or experiences into the routine in order to make it more relatable and engaging for the audience.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -120,7 +120,7 @@ "summary": "\ud83c\udf44Stand-up comedian GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Stand-up comedian's Response\u2935\ufe0e" }, "motiv": { - "prompt": "I want you to act as a motivational coach. I will provide you with some information about someone's goals and challenges, and it will be your job to come up with strategies that can help this person achieve their goals. This could involve providing positive affirmations, giving helpful advice or suggesting activities they can do to reach their end goal. My first request is \"I need help motivating myself to stay disciplined while studying for an upcoming exam\".", + "prompt": "I want you to act as a motivational coach. I will provide you with some information about someone's goals and challenges, and it will be your job to come up with strategies that can help this person achieve their goals. This could involve providing positive affirmations, giving helpful advice or suggesting activities they can do to reach their end goal.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -128,7 +128,7 @@ "summary": "\ud83c\udf44Motivational coach GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Motivational coach's Response\u2935\ufe0e" }, "debate": { - "prompt": "I want you to act as a debater. I will provide you with some topics related to current events and your task is to research both sides of the debates, present valid arguments for each side, refute opposing points of view, and draw persuasive conclusions based on evidence. Your goal is to help people come away from the discussion with increased knowledge and insight into the topic at hand. My first request is \"I want an opinion piece about Deno.\"", + "prompt": "I want you to act as a debater. I will provide you with some topics related to current events and your task is to research both sides of the debates, present valid arguments for each side, refute opposing points of view, and draw persuasive conclusions based on evidence. Your goal is to help people come away from the discussion with increased knowledge and insight into the topic at hand.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -136,7 +136,7 @@ "summary": "\ud83c\udf44Debater GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Debater's Response\u2935\ufe0e" }, "write": { - "prompt": "In order to submit applications for jobs, I want to write a new cover letter. Please compose a cover letter describing my technical skills. I've been working with web technology for two years. I've worked as a frontend developer for 8 months. I've grown by employing some tools. These include [...Tech Stack], and so on. I wish to develop my full-stack development skills. I desire to lead a T-shaped existence. Can you write a cover letter for a job application about myself?", + "prompt": "In order to submit applications for jobs, I want to write a new cover letter. Please compose a cover letter describing my technical skills. Can you write a cover letter for a job application about myself?", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -144,7 +144,7 @@ "summary": "\ud83c\udf44Cover letter GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Cover letter's Response\u2935\ufe0e" }, "script": { - "prompt": "I want you to act as a screenwriter. You will develop an engaging and creative script for either a feature length film, or a Web Series that can captivate its viewers. Start with coming up with interesting characters, the setting of the story, dialogues between the characters etc. Once your character development is complete - create an exciting storyline filled with twists and turns that keeps the viewers in suspense until the end. My first request is \"I need to write a romantic drama movie set in Paris.\"", + "prompt": "I want you to act as a screenwriter. You will develop an engaging and creative script for either a feature length film, or a Web Series that can captivate its viewers. Start with coming up with interesting characters, the setting of the story, dialogues between the characters etc. Once your character development is complete - create an exciting storyline filled with twists and turns that keeps the viewers in suspense until the end.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -495,7 +495,7 @@ "repetition_penalty": 1.17, "summary": "\ud83c\udf44Prompt generator GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Prompt generator's Response\u2935\ufe0e" }, - "db": { + "algo": { "prompt": "I want you to act as an instructor in a school, teaching algorithms to beginners. You will provide code examples using python programming language. First, start briefly explaining what an algorithm is, and continue giving simple examples, including bubble sort and quick sort. Later, wait for my prompt for additional questions. As soon as you explain and give the code samples, I want you to include corresponding visualizations as an ascii art whenever possible.", "temperature": 1.31, "top_p": 0.14, @@ -503,14 +503,6 @@ "repetition_penalty": 1.17, "summary": "\ud83c\udf44Instructor in a school GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Instructor in a school's Response\u2935\ufe0e" }, - "diet": { - "prompt": "I want you to act as a SQL terminal in front of an example database. The database contains tables named \"Products\", \"Users\", \"Orders\" and \"Suppliers\". I will type queries and you will reply with what the terminal would show. I want you to reply with a table of query results in a single code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell you something in English I will do so in curly braces {like this). My first command is 'SELECT TOP 10 * FROM Products ORDER BY Id DESC'", - "temperature": 1.31, - "top_p": 0.14, - "top_k": 49, - "repetition_penalty": 1.17, - "summary": "\ud83c\udf44Sql terminal GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Sql terminal's Response\u2935\ufe0e" - }, "psych": { "prompt": "As a dietitian, I would like to design a vegetarian recipe for 2 people that has approximate 500 calories per serving and has a low glycemic index. Can you please provide a suggestion?", "temperature": 1.31, @@ -536,7 +528,7 @@ "summary": "\ud83c\udf44Journal reviewer GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Journal reviewer's Response\u2935\ufe0e" }, "devrel": { - "prompt": "I want you to act as a Developer Relations consultant. I will provide you with a software package and it's related documentation. Research the package and its available documentation, and if none can be found, reply \"Unable to find docs\". Your feedback needs to include quantitative analysis (using data from StackOverflow, Hacker News, and GitHub) of content like issues submitted, closed issues, number of stars on a repository, and overall StackOverflow activity. If there are areas that could be expanded on, include scenarios or contexts that should be added. Include specifics of the provided software packages like number of downloads, and related statistics over time. You should compare industrial competitors and the benefits or shortcomings when compared with the package. Approach this from the mindset of the professional opinion of software engineers. Review technical blogs and websites (such as TechCrunch.com or Crunchbase.com) and if data isn't available, reply \"No data available\". My first request is \"express https://expressjs.com\"", + "prompt": "I want you to act as a Developer Relations consultant. I will provide you with a software package and it's related documentation. Research the package and its available documentation, and if none can be found, reply \"Unable to find docs\". Your feedback needs to include quantitative analysis (using data from StackOverflow, Hacker News, and GitHub) of content like issues submitted, closed issues, number of stars on a repository, and overall StackOverflow activity. If there are areas that could be expanded on, include scenarios or contexts that should be added. Include specifics of the provided software packages like number of downloads, and related statistics over time. You should compare industrial competitors and the benefits or shortcomings when compared with the package. Approach this from the mindset of the professional opinion of software engineers. Review technical blogs and websites (such as TechCrunch.com or Crunchbase.com) and if data isn't available, reply \"No data available\".", "temperature": 1.31, "top_p": 0.14, "top_k": 49, @@ -544,7 +536,7 @@ "summary": "\ud83c\udf44Developer relations consultant GPT\ud83c\udf44
\u2935\ufe0eClick Here To See Developer relations consultant's Response\u2935\ufe0e" }, "acad": { - "prompt": "I want you to act as an academician. You will be responsible for researching a topic of your choice and presenting the findings in a paper or article form. Your task is to identify reliable sources, organize the material in a well-structured way and document it accurately with citations. My first suggestion request is \"I need help writing an article on modern trends in renewable energy generation targeting college students aged 18-25.\"", + "prompt": "I want you to act as an academician. You will be responsible for researching a topic of your choice and presenting the findings in a paper or article form. Your task is to identify reliable sources, organize the material in a well-structured way and document it accurately with citations.", "temperature": 1.31, "top_p": 0.14, "top_k": 49, diff --git a/plugins/ai.py b/plugins/ai.py index b9cf893..71fd023 100644 --- a/plugins/ai.py +++ b/plugins/ai.py @@ -18,6 +18,7 @@ async def handle_command(room, message, bot, prefix, config): message (RoomMessage): The message object containing the command. bot (Bot): The bot object. prefix (str): The command prefix. + config (dict): Configuration parameters. Returns: None @@ -30,9 +31,6 @@ async def handle_command(room, message, bot, prefix, config): conf = load_config() if command in conf: await handle_ai_command(room, bot, command, match.args(), conf) - #else: - #await bot.api.send_text_message(room.room_id, f"Unknown command: {command}") - #logging.info("Sent unknown command message to the room") async def handle_ai_command(room, bot, command, args, config): """ @@ -43,7 +41,7 @@ async def handle_ai_command(room, bot, command, args, config): bot (Bot): The bot object. command (str): The name of the AI model command. args (list): List of arguments provided with the command. - config: Configuration parameters. + config (dict): Configuration parameters. Returns: None @@ -91,6 +89,15 @@ async def handle_ai_command(room, bot, command, args, config): await bot.api.send_text_message(room.room_id, f"Error generating text: {e}") def markdown_to_html(markdown_text): + """ + Convert Markdown text to HTML. + + Args: + markdown_text (str): Markdown formatted text. + + Returns: + str: HTML formatted text. + """ html_content = markdown2.markdown(markdown_text) return html_content @@ -106,4 +113,3 @@ def load_config(): return config CONFIG = load_config() - diff --git a/plugins/config.py b/plugins/config.py index e8dbe39..144f038 100644 --- a/plugins/config.py +++ b/plugins/config.py @@ -98,13 +98,16 @@ async def handle_command(room, message, bot, prefix, config): 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("set"): + # If the command is 'set', check if it has exactly two arguments args = match.args() if len(args) != 2: await bot.api.send_text_message(room.room_id, "Usage: !set ") return option, value = args + # Set the specified configuration option based on the provided value if option == "admin_user": config.admin_user = value await bot.api.send_text_message(room.room_id, f"Admin user set to {value}") @@ -114,6 +117,7 @@ async def handle_command(room, message, bot, prefix, config): else: await bot.api.send_text_message(room.room_id, "Invalid configuration option") + # If the command is 'get', retrieve the value of the specified configuration option elif match.is_not_from_this_bot() and match.prefix() and match.command("get"): args = match.args() if len(args) != 1: @@ -127,21 +131,24 @@ async def handle_command(room, message, bot, prefix, config): else: await bot.api.send_text_message(room.room_id, "Invalid configuration option") + # If the command is 'saveconf', save the current configuration elif match.is_not_from_this_bot() and match.prefix() and match.command("saveconf"): config.save_config(config.config_file) await bot.api.send_text_message(room.room_id, "Configuration saved") + # If the command is 'loadconf', load the saved configuration elif match.is_not_from_this_bot() and match.prefix() and match.command("loadconf"): config.load_config(config.config_file) await bot.api.send_text_message(room.room_id, "Configuration loaded") + # If the command is 'show', display the current configuration elif match.is_not_from_this_bot() and match.prefix() and match.command("show"): admin_user = config.admin_user prefix = config.prefix await bot.api.send_text_message(room.room_id, f"Admin user: {admin_user}, Prefix: {prefix}") + # If the command is 'reset', reset the configuration to default values elif match.is_not_from_this_bot() and match.prefix() and match.command("reset"): config.admin_user = "" config.prefix = "!" await bot.api.send_text_message(room.room_id, "Configuration reset") - diff --git a/plugins/help.py b/plugins/help.py index 3ca2cf8..3bf6e46 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -71,10 +71,10 @@ async def handle_command(room, message, bot, prefix, config):

-
+
📸 Funguy Bot AI Commands 🌟

-!tech, !music, !eth, !seo, !term, !eng, !intv, !js, !xls, !pron, !spk, !trv, !plag, !char, !adv, !story, !foot, !comic, !motiv, !music, !debate, !write, !script, !author, !crit, !rel, !poem, !rap, !speak, !phil, !math, !tutor, !design, !sec, !recruit, !coach, !etymo, !com, !magic, !counsel, !behavior, !fit, !mh, !realest, !log, !dental, !web, !health, !acc, !chef, !auto, !art, !fin, !invest, !tea, !interior, !florist, !selfhelp, !gnome, !aph, !adv, !advgame, !esc, !title, !stats, !prompt, !teach, !db, !diet, !psych, !domain, !tech, !review, !devrel, !acad, !arch, !insane, !manip, !logic, !review, !diy, !influencer, !philos, !socrat, !edu, !meditate, !writer, !smm, !eloc, !viz, !nav, !hypno, !hist, !astro, !critic, !comp, !journo, !curation, !pscoach, !makeup, !childcare, !writing, !art, !py, !syn, !shop, !dining, !telemed, !cook, !law, !fashion, !ml, !trans, !design, !it, !chess, !prompt, !dev, !math, !regex, !time, !dream, !coach, !r, !comm, !trans, !php, !emergency, !worksheet, !test, !game, !security, !create, !browse, !dev, !search, !startup, !guide, !langdet, !sales, !msg, !ceo, !diag, !coach, !therapy, !legal, !gen, !mgmt, !drunk, !hist, !rec, !write, !techtrans, !ai, !game, !proof, !spirit, !spirit, !chem, !friend, !py, !chat, !wiki, !kanji, !note, !litcrit, !enhance, !travel, !data, !gaming +!tech, !music, !eth, !seo, !eng, !intv, !pron, !spk, !trv, !plag, !char, !adv, !story, !foot, !comic, !motiv, !debate, !write, !script, !author, !crit, !rel, !poem, !rap, !speak, !phil, !math, !tutor, !design, !sec, !recruit, !coach, !etymo, !com, !magic, !counsel, !behavior, !fit, !mh, !realest, !log, !dental, !web, !health, !acc, !chef, !auto, !art, !fin, !invest, !tea, !interior, !florist, !selfhelp, !gnome, !aph, !adv, !advgame, !esc, !title, !stats, !prompt, !teach, !diet, !psych, !domain, !tech, !review, !devrel, !acad, !arch, !insane, !manip, !logic, !review, !diy, !influencer, !philos, !socrat, !edu, !meditate, !writer, !smm, !eloc, !viz, !nav, !hypno, !hist, !astro, !critic, !comp, !journo, !curation, !pscoach, !makeup, !childcare, !writing, !art, !py, !syn, !shop, !dining, !telemed, !cook, !law, !fashion, !ml, !trans, !design, !it, !chess, !prompt, !dev, !math, !regex, !time, !dream, !coach, !r, !comm, !trans, !php, !emergency, !worksheet, !test, !game, !security, !create, !browse, !dev, !search, !startup, !guide, !langdet, !sales, !msg, !ceo, !diag, !coach, !therapy, !legal, !gen, !mgmt, !drunk, !hist, !rec, !write, !techtrans, !ai, !game, !proof, !spirit, !spirit, !chem, !friend, !py, !chat, !wiki, !kanji, !note, !litcrit, !enhance, !travel, !data, !gaming

""" diff --git a/plugins/isup.py b/plugins/isup.py index 8b41274..236ac04 100644 --- a/plugins/isup.py +++ b/plugins/isup.py @@ -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 ") 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") + diff --git a/plugins/proxy.py b/plugins/proxy.py index 9a1c38d..546815a 100644 --- a/plugins/proxy.py +++ b/plugins/proxy.py @@ -9,44 +9,50 @@ import logging import random import requests import socket -import ssl import time from datetime import datetime, timedelta +import concurrent.futures import simplematrixbotlib as botlib +import sqlite3 # Constants SOCKS5_LIST_URL = 'https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt' -MAX_TRIES = 5 +# SOCKS5_LIST_URL = 'https://raw.githubusercontent.com/proxifly/free-proxy-list/main/proxies/protocols/socks5/data.txt' +MAX_TRIES = 64 PROXY_LIST_FILENAME = 'socks5.txt' PROXY_LIST_EXPIRATION = timedelta(hours=8) +MAX_THREADS = 128 +PROXIES_DB_FILE = 'proxies.db' +MAX_PROXIES_IN_DB = 500 -async def test_socks5_proxy(proxy): +# Setup verbose logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def test_proxy(proxy): """ - Test a SOCKS5 proxy by attempting a connection and sending a request through it. + Test a SOCKS5 proxy and return the outcome. Args: proxy (str): The SOCKS5 proxy address in the format 'ip:port'. Returns: - bool: True if the proxy is working, False otherwise. - float: The latency in milliseconds if the proxy is working, None otherwise. + tuple: (bool: success, str: proxy, int: latency) """ try: ip, port = proxy.split(':') + logging.info(f"Testing SOCKS5 proxy: {ip}:{port}") start_time = time.time() - with socket.create_connection((ip, int(port)), timeout=5) as client: + with socket.create_connection((ip, int(port)), timeout=12) as client: client.sendall(b'\x05\x01\x00') response = client.recv(2) if response == b'\x05\x00': latency = int(round((time.time() - start_time) * 1000, 0)) - logging.info(f"Successful connection to SOCKS5 proxy {proxy}. Latency: {latency} ms") - return True, latency + return True, proxy, latency else: - logging.info(f"Failed to connect to SOCKS5 proxy {proxy}: Connection refused") - return False, None + return False, proxy, None except Exception as e: - logging.error(f"Error testing SOCKS5 proxy {proxy}: {e}") - return False, None + return False, proxy, None + async def download_proxy_list(): """ @@ -72,6 +78,69 @@ async def download_proxy_list(): return False +def check_db_for_proxy(): + """ + Check the proxies database for a working proxy. + If found, test the proxy and remove it from the database if it doesn't work. + + Returns: + str or None: The working proxy if found, None otherwise. + """ + try: + with sqlite3.connect(PROXIES_DB_FILE) as conn: + cursor = conn.cursor() + cursor.execute(""" + CREATE TABLE IF NOT EXISTS proxies ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + proxy TEXT, + latency INTEGER, + status TEXT + ) + """) + cursor.execute("SELECT proxy, latency FROM proxies WHERE status = 'working' AND latency < 3000 ORDER BY RANDOM() LIMIT 1") + result = cursor.fetchone() + if result: + proxy, latency = result + success, _, _ = test_proxy(proxy) + if success: + return proxy, latency + else: + cursor.execute("DELETE FROM proxies WHERE proxy = ?", (proxy,)) + conn.commit() + logging.info(f"Removed non-working proxy from the database: {proxy}") + return None, None + else: + return None, None + except Exception as e: + logging.error(f"Error checking proxies database: {e}") + return None, None + + +def save_proxy_to_db(proxy, latency): + """ + Save a working proxy to the proxies database. + + Args: + proxy (str): The working proxy to be saved. + latency (int): Latency of the proxy. + """ + try: + with sqlite3.connect(PROXIES_DB_FILE) as conn: + cursor = conn.cursor() + cursor.execute(""" + CREATE TABLE IF NOT EXISTS proxies ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + proxy TEXT, + latency INTEGER, + status TEXT + ) + """) + cursor.execute("INSERT INTO proxies (proxy, latency, status) VALUES (?, ?, 'working')", (proxy, latency)) + conn.commit() + except Exception as e: + logging.error(f"Error saving proxy to database: {e}") + + async def handle_command(room, message, bot, prefix, config): """ Function to handle the !proxy command. @@ -87,34 +156,58 @@ async def handle_command(room, message, bot, prefix, config): if match.is_not_from_this_bot() and match.prefix() and match.command("proxy"): logging.info("Received !proxy command") - # Download proxy list if needed - if not await download_proxy_list(): - await bot.api.send_markdown_message(room.room_id, "Error downloading proxy list") - logging.error("Error downloading proxy list") + # Check database for a working proxy + working_proxy, latency = check_db_for_proxy() + if working_proxy: + await bot.api.send_markdown_message(room.room_id, + f"✅ Using cached working SOCKS5 Proxy: **{working_proxy}** - Latency: **{latency} ms**") + logging.info(f"Using cached working SOCKS5 proxy {working_proxy}") return - try: - # Read proxies from file - with open(PROXY_LIST_FILENAME, 'r') as f: - socks5_proxies = f.read().splitlines() - random.shuffle(socks5_proxies) + # Download proxy list if needed + else: + if not await download_proxy_list(): + await bot.api.send_markdown_message(room.room_id, "Error downloading proxy list") + logging.error("Error downloading proxy list") + return - # Test proxies - socks5_proxy = None - for proxy in socks5_proxies[:MAX_TRIES]: - success, latency = await test_socks5_proxy(proxy) - if success: - socks5_proxy = proxy - break + try: + # Read proxies from file + with open(PROXY_LIST_FILENAME, 'r') as f: + socks5_proxies = [line.replace("socks5://", "") for line in f.read().splitlines()] + random.shuffle(socks5_proxies) + + # Test proxies concurrently + tested_proxies = 0 + with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_THREADS) as executor: + futures = [] + for proxy in socks5_proxies[:MAX_TRIES]: + futures.append(executor.submit(test_proxy, proxy)) + for future in concurrent.futures.as_completed(futures): + success, proxy, latency = future.result() + if success: + await bot.api.send_markdown_message(room.room_id, + f"✅ Anonymous SOCKS5 Proxy: **{proxy}** - Latency: **{latency} ms**") + logging.info(f"Sent SOCKS5 proxy {proxy} to the room") + save_proxy_to_db(proxy, latency) # Save working proxy to the database + tested_proxies += 1 + if tested_proxies >= MAX_PROXIES_IN_DB: + break # Stop testing proxies once MAX_PROXIES_IN_DB are saved to the database + + # Check database for a working proxy after testing + working_proxy, latency = check_db_for_proxy() + if working_proxy: + await bot.api.send_markdown_message(room.room_id, + f"✅ Using cached working SOCKS5 Proxy: **{working_proxy}** - Latency: **{latency} ms**") + logging.info(f"Using cached working SOCKS5 proxy {working_proxy}") + + else: + # If no working proxy found after testing + await bot.api.send_markdown_message(room.room_id, "❌ No working anonymous SOCKS5 proxy found") + logging.info("No working anonymous SOCKS5 proxy found") + + except Exception as e: + logging.error(f"Error handling !proxy command: {e}") + await bot.api.send_markdown_message(room.room_id, "❌ Error handling !proxy command") - # Send the first working anonymous proxy of each type to the Matrix room - if socks5_proxy: - await bot.api.send_markdown_message(room.room_id, f"✅ Anonymous SOCKS5 Proxy: **{socks5_proxy}** - Latency: **{latency} ms**") - logging.info(f"Sent SOCKS5 proxy {socks5_proxy} to the room") - else: - await bot.api.send_markdown_message(room.room_id, "❌ No working anonymous SOCKS5 proxy found") - logging.info("No working anonymous SOCKS5 proxy found") - except Exception as e: - logging.error(f"Error handling !proxy command: {e}") - await bot.api.send_markdown_message(room.room_id, "❌ Error handling !proxy command") diff --git a/plugins/youtube-preview.py b/plugins/youtube-preview.py index 9885bdc..477ed63 100644 --- a/plugins/youtube-preview.py +++ b/plugins/youtube-preview.py @@ -6,8 +6,13 @@ Plugin for providing a command to fetch YouTube video information from links. import re import logging import asyncio +import aiohttp from pytubefix import YouTube import simplematrixbotlib as botlib +from youtube_title_parse import get_artist_title + +LYRICIST_API_URL = "https://lyrist.vercel.app/api/song/{}" + def seconds_to_minutes_seconds(seconds): """ @@ -23,6 +28,28 @@ def seconds_to_minutes_seconds(seconds): seconds %= 60 return f"{minutes:02d}:{seconds:02d}" + +async def fetch_lyrics(artist): + """ + Asynchronously fetches lyrics for a song from the Lyricist API. + + Args: + artist (str): The name of the artist. + + Returns: + str: Lyrics of the song. + None if an error occurs during fetching. + """ + try: + async with aiohttp.ClientSession() as session: + async with session.get(LYRICIST_API_URL.format(artist)) as response: + data = await response.json() + return data.get("lyrics") + except Exception as e: + logging.error(f"Error fetching lyrics: {str(e)}") + return None + + async def fetch_youtube_info(youtube_url): """ Asynchronously fetches information about a YouTube video. @@ -37,17 +64,27 @@ async def fetch_youtube_info(youtube_url): try: video = YouTube(youtube_url) title = video.title + artist, song = get_artist_title(title) + description = video.description length = seconds_to_minutes_seconds(video.length) views = video.views author = video.author description_with_breaks = description.replace('\n', '
') - info_message = f"""🎬🎝 Title: {title} | Length: {length} minutes | Views: {views}\n
⤵︎Click Here For Description⤵︎{description_with_breaks}
""" + + # Fetching lyrics + lyrics = await fetch_lyrics(artist) + lyrics = lyrics.replace('\n', "
") + + info_message = f"""🎬🎝 Title: {title} | Length: {length} minutes | Views: {views}\n
⤵︎Description⤵︎{description_with_breaks}
""" + if lyrics: + info_message += f"
🎵 Lyrics:
{lyrics}
" return info_message except Exception as e: logging.error(f"Error fetching YouTube video information: {str(e)}") return None + async def handle_command(room, message, bot, prefix, config): """ Asynchronously handles the command to fetch YouTube video information. diff --git a/requirements.txt b/requirements.txt index 65e94f7..269f3ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,6 @@ markdown2 watchdog emoji python-slugify +youtube_title_parse + +