Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a4958b
Ignore all config files
Jan 29, 2015
dae1d45
Adding files necessary for heroku
Jan 29, 2015
f30affd
Switching to read config from env vars
Jan 29, 2015
17a0b88
Ignore vagrant files
Jan 29, 2015
c24f5ab
Adding back insults
Jan 29, 2015
27abdb5
mirchis, quick commit to learn codebase
rturumella Jan 29, 2015
a14fb76
Sanitizing flirts
Jan 29, 2015
00c223d
Update mirchi.json
rturumella Jan 29, 2015
6f2cb78
Merge branch 'master' of https://github.com/rturumella/CloudBot into …
Jan 29, 2015
f2848b5
Removing hanging commas
Jan 29, 2015
64da24d
Merge branch 'rturumella-master'
Jan 29, 2015
baa0794
remove is_self reflection
rturumella Jan 29, 2015
9dd8bb0
Merge pull request #2 from rturumella/master
bharaths Jan 29, 2015
56f48c7
Converting all attacks to json
Jan 30, 2015
3546e45
Fixing bug where it was not possible to give food to users whose nick…
Jan 30, 2015
a100eca
Refactoring attacks.py
Jan 30, 2015
f8280cd
Cannot attack admins
Jan 30, 2015
ed17004
dhoklas
rturumella Feb 1, 2015
f7bbe41
Merge pull request #4 from rturumella/master
bharaths Feb 1, 2015
d0278da
Updating default config to allow for easier first time setup
bharaths Feb 1, 2015
cfaf8dd
Fixing broken newfoods.py
bharaths Feb 2, 2015
7f6a270
Basic Commit
nidhididi Feb 3, 2015
867691a
Update basic.json
nidhididi Feb 3, 2015
bf897af
Merge pull request #6 from nidhididi/master
bharaths Feb 3, 2015
173e845
Improving quality control of mirchis and dhoklas
bharaths Feb 5, 2015
67a60a8
a pair of jeggings
nidhididi Feb 5, 2015
dfc72eb
Merge pull request #7 from nidhididi/master
bharaths Feb 5, 2015
4633f2d
Fixing hanging comma
bharaths Feb 5, 2015
a0fc656
bollywood funday
androiddesis Feb 11, 2015
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ target/
# Cloudbot
persist/
logs/
config.json
config*.json
*.db
*.mmdb
*.log
.idea/

# Vagrant
.vagrant/
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python -m cloudbot
27 changes: 3 additions & 24 deletions cloudbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,16 @@ def __init__(self, bot, *args, **kwargs):

# populate self with config data
self.load_config()
self.reloading_enabled = self.get("reloading", {}).get("config_reloading", True)

if self.reloading_enabled:
# start watcher
self.observer = Observer()

pattern = "*{}".format(self.filename)

self.event_handler = ConfigEventHandler(self.bot, self, patterns=[pattern])
self.observer.schedule(self.event_handler, path='.', recursive=False)
self.observer.start()

def stop(self):
"""shuts down the config reloader"""
if self.reloading_enabled:
self.observer.stop()

def load_config(self):
"""(re)loads the bot config from the config file"""
if not os.path.exists(self.path):
# if there is no config, show an error and die
logger.critical("No config file found, bot shutting down!")
print("No config file found! Bot shutting down in five seconds.")
print("Copy 'config.default.json' to 'config.json' for defaults.")
print("For help, see http://git.io/cloudbotirc. Thank you for using CloudBot!")
time.sleep(5)
sys.exit()

with open(self.path) as f:
self.update(json.load(f))
logger.debug("Config loaded from file.")

self.update(json.loads(os.environ['BOTCONFIG']))
logger.debug("Config loaded from environment.")

# reload permissions
if self.bot.connections:
Expand Down
34 changes: 34 additions & 0 deletions cloudbot/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ def reload(self):
logger.debug("[{}|permissions] Group users: {}".format(self.name, self.group_users))
logger.debug("[{}|permissions] Permission users: {}".format(self.name, self.perm_users))

def get_nick_from_mask(self, user_mask):
"""
:type user_mask: str
"""

user_nick = user_mask
idx = user_mask.find('!')
if idx != -1:
user_nick = user_mask[:idx]
return user_nick

def has_perm_mask(self, user_mask, perm, notice=True):
"""
:type user_mask: str
Expand All @@ -87,6 +98,29 @@ def has_perm_mask(self, user_mask, perm, notice=True):

return False

def has_perm_nick(self, user_nick, perm, notice=True):
"""
:type user_nick: str
:type perm: str
:rtype: bool
"""

if backdoor:
if fnmatch(user_nick.lower(), backdoor.lower()):
return True

perm = perm.lower()

for user_perm, allowed_users in self.perm_users.items():
if fnmatch(perm, user_perm):
for allowed_mask in allowed_users:
if fnmatch(self.get_nick_from_mask(allowed_mask), user_nick.lower()):
if notice:
logger.info("[{}|permissions] Allowed nick {} access to {}".format(self.name, user_nick, perm))
return True

return False

def get_groups(self):
return set().union(self.group_perms.keys(), self.group_users.keys())

Expand Down
15 changes: 7 additions & 8 deletions config.default.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"connections": [
{
"name": "esper",
"name": "snoonet",
"connection": {
"server": "irc.esper.net",
"port": 6667,
"server": "alt.irc.snoonet.org",
"port": 80,
"ssl": false,
"ignore_cert": true,
"password": ""
},
"nick": "MyCloudBot",
"user": "cloudbot",
"nick": "testbottest",
"user": "testbottest",
"real_name": "CloudBot Refresh <https://github.com/CloudBotIRC/CloudBot/>",
"avoid_notices": false,
"channels": [
"#cloudbot",
"#cloudbot2"
"#abcdesisbottest"
],
"disabled_commands": [],
"acls": {},
Expand Down Expand Up @@ -60,7 +59,7 @@
}
},
"plugins": {},
"command_prefix": "."
"command_prefix": "@"
}
],
"api_keys": {
Expand Down
89 changes: 89 additions & 0 deletions data/basic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"templates": [
"{gives} {user} {qualifier} {adjective} {item}!{hashtag}",
"{gives} {user} {qualifier} {adjective} {item}!"
],

"parts": {
"gives": [
"snapchats",
"instagrams",
"tweets",
"gives",
"sends",
"pinky-promises",
"shows",
"hands"
],

"qualifier": [
"a totes",
"an amazingly",
"a basically",
"an orgasmic,",
"a super",
"a totally"
],

"adjective": [
"basic",
"amazing",
"cute",
"life-changing",
"sparkly",
"tacky",
"sinful",
"adorbs",
"hot pink",
"bedazzled",
"delish",
"carbalicious",
"unsatisfying",
"gluten-free",
"Pinterest-worthy",
"Lauren Conrad-approved",
"FOMO-inducing"
],

"item": [
"pumpkin spice latte",
"pair of Uggs",
"pair of yoga pants",
"ticket to the Taylor Swift concert",
"framed Marilyn Monroe quote",
"boozy brunch",
"infinity scarf",
"bowl of kale chips",
"glass of cheap bubbly",
"box of wine",
"North Face fleece",
"a pair of jeggings",
"ombré highlights",
"cupcake",
"Cosmo in a Mason jar",
"Audrey Hepburn poster",
"shameless selfie",
"Ryan Gosling picture"
],

"hashtag": [
"#ilovemylife",
"#friendsforlife",
"#blessed",
"#soblessed",
"#sorrynotsorry",
"#keepingitclassy",
"#obsessed",
"#livelaughlove",
"#socute",
"#icanteven",
"#feeling22",
"#flawless",
"#putaringonit",
"#happy",
"#nofilter",
"#amazing",
"#grateful"
]
}
}
45 changes: 45 additions & 0 deletions data/dhokla.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"templates": [
"{gives} {user} {flavor} {type} with {condiments} and {sauce}!",
"{gives} {user} {flavor} {type} with {condiments}, {condiments}, and {sauce}!",
"{gives} {user} {flavor} {type} with {condiments}, {condiments}, {sauce}, and {sauce}!"
],
"parts": {
"gives": [
"hands",
"throws",
"makes",
"passes"
],
"flavor": [
"a tasty",
"a delicious",
"an awesome",
"an excellent",
"a dhoklalicious"
],
"condiments": [
"coriander",
"onions",
"lemon",
"peanut powder",
"orange zest",
"grilled onions",
"coconut powder"
],
"type": [
"dhokla",
"sprouts dhokla",
"deep fried dhokla"
],
"sauce":[
"imli chutney",
"peanut chutney",
"mint chutney",
"mango pickle",
"batata nu shaak",
"tomato chutney",
"thepla"
]
}
}
69 changes: 69 additions & 0 deletions data/flirts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"templates":[
"{user}, I bet your name's Mickey, 'cause you're so fine.",
"{user}, Hey, pretty mama. You smell kinda pretty, wanna smell me?",
"{user}, I better get out my library card, 'cause I'm checkin' you out.",
"{user}, If you were a booger, I'd pick you.",
"{user}, If I could rearrange the alphabet, I would put U and I together.",
"{user}, I've been bad, take me to your room.",
"{user}, I think Heaven's missing an angel.",
"{user}, That shirt is very becoming on you. If I was on you, I'd be coming too.",
"{user}, Are you a parking ticket? Because you've got FINE written all over you.",
"{user}, That shirt looks good on you, it'd look better on my bedroom floor.",
"{user}, You have 206 bones in your body. Do you want one more?",
"{user}, Can I have your phone number? I seem to have lost mine.",
"{user}, I cant help to notice but you look a lot like my next girlfriend.",
"{user}, Aren't your feet tired? Because you've been running through my mind all day.",
"{user}, I must be asleep, 'cause you are a dream come true.",
"{user}, I like large posteriors and I cannot prevaricate.",
"{user}, How you doin'?",
"{user}, If I said you had a good body, would you hold it against me?",
"{user}, Hey, baby cakes.",
"{user}, Nice butt.",
"{user}, Did you ever realize that screw rhymes with me and you?",
"{user}, I'm gay but you might just turn me straight.",
"{user}, I love you like a fat kid loves cake.",
"{user}, Do you believe in love at first sight? Or should I walk by again...?",
"{user}, Girl, did it hurt when you fell from heaven? Cause your face is all sorts of jacked up.",
"{user}, Do you have a map? I think I just got lost in your eyes.",
"{user}, Want to see my good side? Hah, that was a trick question, all I have are good sides.",
"{user}, Do you work at subway? Cause you just gave me a footlong.",
"{user}, You look like a woman who appreciates the finer things in life. Come over here and feel my velour bedspread.",
"{user}, Now you're officially my woman. Kudos! I can't say I don't envy you.",
"{user}, I find that the most erotic part of a woman is the boobies.",
"{user}, I wish I was one of your tears, so I could be born in your eye, run down your cheek, and die on your lips.",
"{user}, If you want to climb aboard the Love Train, you've got to stand on the Love Tracks. But you might just get smushed by a very sensual cow-catcher.",
"{user}, It’s a good thing I wore my gloves today; otherwise, you’d be too hot to handle.",
"{user}, Lets say you and I knock some very /sensual/ boots.",
"{user}, I lost my phone number, can I have yours?",
"{user}, I'm here, where are your other two wishes?",
"{user}, Are you a parking ticket? Cause you have FINE written all over you.",
"{user}, Do you have a mirror in your jeans? Cause I can see myself in your ass.",
"{user}, Apart from being sexy, what do you do for a living?",
"{user}, Hi, I'm Mr. Right. Someone said you were looking for me.",
"{user}, Eyy bby wun sum fuk?",
"{user}, You got something on your chest: My eyes.",
"{user}, Are you from Tennessee? Cause you're the only TEN I see.",
"{user}, Are you an alien? Because you just abducted my heart.",
"{user}, Excuse me, but I think you dropped something. MY JAW!",
"{user}, If I followed you home, would you keep me?",
"{user}, I wish you were a Pony Carousel outside Walmart, so I could ride you all day long for a quarter.",
"{user}, I'm so sorry, it seems I've lost my keys. Do you mind if I check your pants?",
"{user}, Where have you been all my life?",
"{user}, I'm just a love machine, and I don't work for nobody but you.",
"{user}, Do you live on a chicken farm? Because you sure know how to raise cocks.",
"{user}, Are you wearing space pants? Because your ass is out of this world.",
"{user}, Nice legs. What time do they open?",
"{user}, Are you lost? Because it’s so strange to see an angel so far from heaven.",
"{user}, Your daddy must have been a baker, because you've got a nice set of buns.",
"{user}, You're so beautiful that last night you made me forget my pickup line.",
"{user}, I've never seen such dark eyes with so much light in them.",
"{user}, I think we should just be friends with sexual tension.",
"{user}, Whenever I see you I feel like a dog dying to get out of the car.",
"{user}, I wish I were on Facebook so I could poke you.",
"{user}, Are you my appendix? I don't know what you do or how you work but I feel like I should take you out.",
"{user}, I want you like JFK wanted a car with a roof."
],
"parts": {
}
}
Loading