Skip to content

Commit

Permalink
plugin: add random image plugin. (#154)
Browse files Browse the repository at this point in the history
* Added random image plugin.

* reformatted with black.

* ran black formatter on info.
  • Loading branch information
rakeshseal0 authored Oct 6, 2022
1 parent bc1e27c commit 336add6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
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

0 comments on commit 336add6

Please sign in to comment.