Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into hangmanPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
IronPenguin4179 committed Apr 4, 2019
2 parents bcbee52 + a2941ea commit 46d3957
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 81 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/)
![Open Source Love](https://img.shields.io/badge/Open%20Source-%E2%9D%A4-pink.svg)
![Open Source Love](https://img.shields.io/badge/chat%20on-discord-green.svg)
![MadeinMoris](https://img.shields.io/badge/Made%20in-Moris-green.svg)

# 🍯 honeybot py
Expand All @@ -13,7 +14,7 @@ Feel free to contribute to the project!

## 🕹 Project Motivation
Implementing the project in Java was weird, py's connect was sleek. Thus, the project stack was shifted over to Python.
If you can think of any features, plugins, or functionality you wish to see in the project. Feel free to add it yourself, or create an issue detailing your ideas. We highly recommend you attempt to implement it yourself first and ask for help in our slack page!
If you can think of any features, plugins, or functionality you wish to see in the project. Feel free to add it yourself, or create an issue detailing your ideas. We highly recommend you attempt to implement it yourself first and ask for help in our discord server!

Psst. since i learnt py through this bot, we decided to keep a new-comers friendly policy. Feeling lost? Just ping.

Expand All @@ -27,13 +28,20 @@ get issues delivered in your inbox.

[![Open Source Helpers](https://www.codetriage.com/abdur-rahmaanj/honeybot/badges/users.svg)](https://www.codetriage.com/abdur-rahmaanj/honeybot)

## Discord
https://discord.gg/E6zD4XT

## :thought_balloon: Project Testimonials
[@TannerFry](https://github.com/TannerFry)

> With experience in programming in Python, and implementing an SMTP email plugin for a different system, picking up HoneyBot and following the documentation provided for new-comers made it very simple to implement the same SMTP email plugin to the HoneyBot system. This was my first time contributing to an open-source
project on GitHub and it was an overall great experience. The welcoming of new contributors and documentation on how to contribute and implement plugins is great for people
who have never contributed to a project before, and Abdur-Rahmaan Janhangeer was extremely helpful when answering my questions and helping me along the way.

[@RiceAbove](https://github.com/RiceAbove)

> HoneyBot is my first time collaborating to an open source project and I'm loving it. Before discovering HoneyBot, I was very intimidated on the idea of working with other people and had no idea what an IRC even was. Now I realize how much fun and rewarding it is to work together on a project with dedicated and friendly individuals. The documentation is easy to follow and everyone is super helpful. I highly recommend any new programmer who want to contribute on an open source project to try out HoneyBot. Personally I enjoy working on this project more than my own schoolwork.
## ✂ Current Features
* 🍬 OOP architecture
* 🛰️ keyword parameters
Expand Down Expand Up @@ -237,8 +245,6 @@ username
## 📧 Contact
### Email
- Abdur-Rahmaan Janhangeer | [email protected]
### Discord
https://discord.gg/E6zD4XT

## 🖊 Credits
[@arwinneil](https://github.com/arwinneil) for opensource and madeinmoris badges
2 changes: 1 addition & 1 deletion honeybot/CONNECT.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

server_url = chat.freenode.net
port = 6667
name = hb_tst00
name = hb_tst003
6 changes: 4 additions & 2 deletions honeybot/PLUGINS.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
greet
username
joke
dictionary
maths
test
calc
caesar_cipher
debug
quote
selfTrivia
dictionary
password_generator
bitcoin
password_generator
wikipedia
weather
mail

45 changes: 26 additions & 19 deletions honeybot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import configparser
import importlib
import socket
import sys

config = configparser.ConfigParser()
config.read('CONNECT.conf')
Expand Down Expand Up @@ -114,20 +115,22 @@ def join(self, channel):
def load_plugins(self, list_to_add):
print("\033[0;36mLoading plugins...\033[0;0m")

try:
to_load = []
with open('PLUGINS.conf', 'r') as f:
to_load = f.read().split('\n')
to_load = list(filter(lambda x: x != '', to_load))
for file in to_load:

to_load = []
with open('PLUGINS.conf', 'r') as f:
to_load = f.read().split('\n')
to_load = list(filter(lambda x: x != '', to_load))
for file in to_load:
try:
module = importlib.import_module('plugins.'+file)
obj = module.Plugin
list_to_add.append(obj)
except ModuleNotFoundError as e:
print('module not found', e, 'in', file)
obj = module.Plugin
list_to_add.append(obj)

self.plugins = list_to_add
print("\033[0;32mLoaded plugins...\033[0;0m")

self.plugins = list_to_add
print("\033[0;32mLoaded plugins...\033[0;0m")
except ModuleNotFoundError as e:
print('module not found', e)

def methods(self):
return {
Expand All @@ -141,14 +144,14 @@ def run_plugins(self, listfrom, incoming):
incoming is the unparsed string. refer to test.py
'''

print(f"\033[0;36mListfrom is {listfrom}\033[0;0m")
print(f"\033[0;33mInfo is {self.info(incoming)}\033[0;0m")
#print(f"\033[0;36mListfrom is {listfrom}\033[0;0m")
#print(f"\033[0;33mInfo is {self.info(incoming)}\033[0;0m")

if self.info(incoming)['args'][1][0] == ".":
print("\033[0;32mReceived!\033[0;0m")
#print("\033[0;32mReceived!\033[0;0m")

for plugin in listfrom:
print(f"\033[0;33mTrying {plugin}\033[0;0m")
#print(f"\033[0;33mTrying {plugin}\033[0;0m")
plugin.run(self, incoming, self.methods(), self.info(incoming))

'''
Expand Down Expand Up @@ -191,7 +194,8 @@ def pull(self):
""".format(msg))
if len(data) == 0:
try:
print('<must handle reconnection>')
print('<must handle reconnection - len(data)==0>')
sys.exit()
except Exception as e:
print(e)
except Exception as e:
Expand All @@ -208,17 +212,20 @@ def registered_run(self):
def unregistered_run(self):
self.connect()
self.greet()
self.load_plugins(plugins)
self.load_plugins(self.plugins)
self.pull()

'''
ONGOING REQUIREMENT/S
'''
def stay_alive(self, incoming):
if not incoming:
print('<must handle reconnection - incoming is not True>')
sys.exit()
if 'ping' in incoming.lower():
part = incoming.split(':')
if self.domain in part[1]:
self.send(self.pong_return())
self.send(self.pong_return() + ":{0}".format(part[1]))
print('''
***** message *****
ping detected from
Expand Down
10 changes: 5 additions & 5 deletions honeybot/plugins/bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def __init__(self):

def run(self, incoming, methods, info):
try:
msgs = info['args'][1:][0].split()
#msgs = info['args'][1:][0].split()

if info['command'] == 'PRIVMSG' and msgs[0] == '.btc':
response = requests.get("https://api.coinmarketcap.com/v1/ticker/bitcoin/")
response_json = response.json()
methods['send'](info['address'], "$" + response_json[0]['price_usd'])
if info['command'] == 'PRIVMSG' and info['args'][1] == '.btc':
response = requests.get("https://api.coinmarketcap.com/v1/ticker/bitcoin/")
response_json = response.json()
methods['send'](info['address'], "$" + response_json[0]['price_usd'])

except Exception as e:
print('woops plugin', __file__, e)
19 changes: 7 additions & 12 deletions honeybot/plugins/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,20 @@
returns meaning of the word specified
"""

import PyDictionary

from PyDictionary import PyDictionary

class Plugin:
def __init__(self):
pass

def __dictionary(self, word):
return PyDictionary().meaning(word).get('Noun')

def run(self, incoming, methods, info):
try:
# if '!~' in info['prefix']:
# print(info)
msgs = info['args'][1:][0].split()
if info['command'] == 'PRIVMSG':
if len(msgs) > 1:
if msgs[0] == '.dictionary':
word = msgs[1]
methods['send'](info['address'], Plugin.__dictionary(self, word))

if info['command'] == 'PRIVMSG' and msgs[0] == '.dictionary':
dict = PyDictionary()
word = str(msgs[1])
defin = dict.meaning(word)['Noun']
methods['send'](info['address'], '{}'.format(defin))
except Exception as e:
print('woops plug', e)
139 changes: 139 additions & 0 deletions honeybot/plugins/monopolyassets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Game Objects
class Property:
def __init__(self, name, color, price,
rent, one_house_rent, two_house_rent,
three_house_rent, four_house_rent, hotel_rent,
build_cost):
self.name = name
self.color = color
self.price = price
self.rents = {"one":one_house_rent,
"two":two_house_rent,
"three":three_house_rent,
"four":four_house_rent,
"hotel":hotel_rent}
self.build_cost = build_cost


class Railroad:
def __init__(self, name):
self.name = name
self.price = 200
self.rents = {"one_railroad":25,
"two_railroad":50,
"three_railroad":100,
"four_railroad":200}


class Utility:
def __init__(self, name):
self.name = name
self.price = 150
self.rents = {"one_utility":"4x"
"two_utility":"10x"}


# Assets
currencies = [1,5,10,20,50,100,500]

board_spaces = {
1:"GO",
2:Property("Mediterranean Ave.","Violet",60,2,10,30,90,160,250,50),
3:"Draw Community Card",
4:Property("Baltic Ave.","Violet",60,4,20,60,180,320,450,50),
5:"Income Tax",
6:Railroad("Reading Railroad"),
7:Property("Oriental Ave.","Light blue",100,6,30,90,270,400,550,50),
8:"Draw Chance Card",
9:Property("Vermont Ave.","Light blue",100,6,30,90,270,400,550,50),
10:Property("Connecticut Ave.","Light blue",120,8,40,100,300,450,600,50),
11:"Jail",
12:Property("St. Charles Pl.","Purple",140,10,50,150,450,625,750,100),
13:Utility("Electric Company"),
14:Property("States Ave.","Purple",140,10,50,150,450,625,750,100),
15:Property("Virginia Ave.","Purple",160,12,60,180,500,700,900,100),
16:Railroad("Pennsylvania Railroad"),
17:Property("St. James Pl.","Orange",180,14,70,200,550,750,950,100),
18:"Draw Community Card",
19:Property("Tennessee Ave.","Orange",180,14,70,200,550,750,950,100),
20:Property("New York Ave.","Orange",200,16,80,220,600,800,1000,100),
21:"Free Parking",
22:Property("Kentucky Ave.","Red",220,18,90,250,700,875,1050,150),
23:"Draw Chance Card",
24:Property("Indiana Ave.","Red",220,18,90,250,700,875,1050,150),
25:Property("Illinois Ave.","Red",240,20,100,300,750,925,1100,150),
26:Railroad("B. & O. Railroad"),
27:Property("Atlantic Ave.","Yellow",260,22,110,330,800,975,1150,150),
28:Property("Ventnor Ave.","Yellow",260,22,110,330,800,975,1150,150),
29:Utility("Water Works"),
30:Property("Marvin Gardens","Yellow",280,24,120,360,850,1025,1200,150),
31:"Go to Jail",
32:Property("Pacific Ave.","Green",300,26,130,390,900,1100,1275,200),
33:Property("No. Carolina Ave.","Green",300,26,130,390,900,1100,1275,200),
34:"Draw Community Card",
35:Property("Pennsylvania Ave.","Green",320,28,150,450,1000,1200,1400,200),
36:Railroad("Short Line Railroad"),
37:"Draw Chance Card",
38:Property("Park Place","Blue",350,35,175,500,1100,1300,1500,200),
39:"Luxury Tax",
40:Property("Boardwalk","Blue",400,50,200,600,1400,1700,2000,200)
}

game_board = [
[ [11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21] ],
[ [10], [22] ],
[ [ 9], [23] ],
[ [ 8], [24] ],
[ [ 7], [25] ],
[ [ 6], [26] ],
[ [ 5], [27] ],
[ [ 4], [28] ],
[ [ 3], [29] ],
[ [ 2], [30] ],
[ [ 1],[40],[39],[38],[37],[36],[35],[34],[33],[32],[31] ]
]

chance_deck = {
1:"You have been elected chairman of the board, pay each player $50",
2:"Take a ride on the reading, if you pass GO collect $200",
3:"Take a walk on the board walk, advance token to board walk",
4:"Advance to go, collect $200",
5:"Advance token to the nearest Railroad and pay owner Twice the " +
" Rental owed. If Railroad is unowned you may buy it from the bank",
6:"Advance token to the nearest Railroad and pay owner Twice the" +
" Rental owed. If Railroad is unowned you may buy it from the bank",
7:"Get out of jail free. This card may be kept until needed or sold",
8:"Go directly to jail. Do not pass Go, do not collect $200",
9:"Bank pays you dividend of $50",
10:"Advance to Illinois Ave",
11:"Pay poor tax of $15",
12:"Make general repairs on all your property. For each house pay " +
"$25, for each hotel $100",
13:"Advance to St. Charles Place. If you pass Go, collect $200",
14:"Your building and loan matures. Collect $150",
15:"Advance token to nearest utility. If Unowned you may buy it " +
"from the bank. If owned throw dice and pay owner ten times the " +
"amount thrown",
16:"Go back 3 spaces"
}

community_deck = {
1:"Get out of jail free. This card may be kept until needed or sold",
2:"From sale of stock, you get $45",
3:"Grand opera opening." +
"Collect $50 from every player for opening night seats",
4:"Advance to Go, collect $200",
5:"Xmas fund matures, collect $100",
6:"Go directly to jail. Do not pass Go. Do not collect $200",
7:"Life insurance matures, collect $200",
8:"You are assessed for street repairs. $40 per house," +
"$115 per hotel",
9:"Pay hospital $100",
10:"Income tax refund, collect $20",
11:"Doctor's fee, pay $50",
12:"You inherit $100",
13:"Pay school tax of $150",
14:"Receive for services $25",
15:"Bank error in your favor, collect $200",
16:"You have won second prize in a beauty contest, collect $10"
}
Loading

0 comments on commit 46d3957

Please sign in to comment.