Using Imports to Make Bots More Efficient 04-05-2014, 07:07 AM
#1
As some of you know, I specialize in bot creation for Python. What a let down, I know, especially for @"Monotonous" , however, my abilities aren't this thread's topic.
I call this method "Spining". Basically you add a "spine" or back bone to the bots so you can use defined commands from another module. This helps cleaning up bots' base file quite a bit.
Example of usage:
Of course, you can add anything you want, this is just made to help make bots cleaner and more efficient.
Spine.py Exmaple:
But why is this spining shit thingy important to bots? Well, basically, by importing our module that stores the commands that we define, we can butt fuck the bot files and shorten them a lot. I'll give you a quick example, a bot that I've written is more than 1000 lines long. I applied the spining method, cleaned it up quite a bit, and the end result was more then half of what it was.
The trick is knowing how to use imports with Python. I'll go more into depth in this topic in another thread, this is just a way to shorten, and clean your bot files.
I call this method "Spining". Basically you add a "spine" or back bone to the bots so you can use defined commands from another module. This helps cleaning up bots' base file quite a bit.
Example of usage:
Code:
import spine
x = input('Cmd>_ ')
if x == 'image':
print(spine.Image(input('')))
if x == 'help':
print(spine.help())
###########################
#Cmd>_ image #
#dubstep #
#returns image link of "dubstep"#
##########################Of course, you can add anything you want, this is just made to help make bots cleaner and more efficient.
Spine.py Exmaple:
Code:
import re,random
import urllib.request as request
def Image(query):
item = request.urlopen("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s" % "+".join(query))
listings = item.read().decode()
applicants = re.finditer('"unescapedUrl":"(.+?)","url":"',listings)
finalGroup = []
for listItem in applicants:
listItem = str(listItem.group(1))
finalGroup.append(listItem)
rel = random.choice(finalGroup)
rel = rel.replace('https','http')
return rel
def help():
cmdList = ['image','help']
return cmdListBut why is this spining shit thingy important to bots? Well, basically, by importing our module that stores the commands that we define, we can butt fuck the bot files and shorten them a lot. I'll give you a quick example, a bot that I've written is more than 1000 lines long. I applied the spining method, cleaned it up quite a bit, and the end result was more then half of what it was.
The trick is knowing how to use imports with Python. I'll go more into depth in this topic in another thread, this is just a way to shorten, and clean your bot files.
![[Image: BXqGARG.png]](https://i.imgur.com/BXqGARG.png)










![[+]](https://sinister.li/images/modern/collapse_collapsed.png)