Skip to content

Added random image plugin. #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ GUI clients are used to manage plugins, launch bot as well as specify credential
| :page_with_curl: comic | Returns a random comic | [@mboekhold](https://github.com/mboekhold) |
| 📝 todo | Makes a to do list | [@h-ranjan1110](https://github.com/h-ranjan1110) |
| 🎱 Magic 8 Ball | Answer questions using magic 8 ball | [@ZakariaTalhami](https://github.com/ZakariaTalhami) |
| 🦆 DuckDuckGo Search | Search queries in duckduckgo and return abstract. | [@rakeshseal0](https://github.com/rakeshseal0) |

| 🖼 Random Image | Returns a random image url. | [@rakeshseal0](https://github.com/rakeshseal0)
| 🦆 DuckDuckGo Search | Search queries in duckduckgo and return abstract. | [@rakeshseal0](https://github.com/rakeshseal0) |
## ⚡ Quickstart

setup
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions src/honeybot/plugins/downloaded/random_image/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NAME = "random_image.py"
ORIGINAL_AUTHORS = ["Rakesh Seal"]

ABOUT = """
Returns a random image url.
"""

COMMANDS = """
>>> .random_image
returns a random image url.
"""
33 changes: 33 additions & 0 deletions src/honeybot/plugins/downloaded/random_image/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""
[random_image.py]
Random Image Plugin

[Author]
Rakesh Seal

[About]
Returns a random image url.
[Website]


[Commands]
>>> .random_image
returns a random image url.
"""

import requests


class Plugin:
def __init__(self):
self.url = "https://random.imagecdn.app/v1/image?width=500&height=150&category=buildings&format=json"

def run(self, incoming, methods, info, bot_info):
try:
msgs = info["args"][1:][0].split()
if info["command"] == "PRIVMSG" and msgs[0] == ".random_image":
image_url = requests.get(self.url).json()["url"]
methods["send"](info["address"], image_url)
except Exception as e:
print("blank!", e)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests