Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.43 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import requests
  4. import random
  5.  
  6. bot = commands.Bot(command_prefix='.')
  7.  
  8.  
  9. def isint(s):
  10.     try:
  11.         int(s)
  12.         return True
  13.     except ValueError:
  14.         return False
  15.  
  16.  
  17. async def do_removal(message, limit, predicate):
  18.     if message.channel.permissions_for(message.author).manage_messages or message.author.id == '205346839082303488':
  19.         await bot.purge_from(message.channel, limit=limit, before=message, check=predicate)
  20.     else:
  21.         await bot.say('not enuff perms')
  22.  
  23.  
  24. class Public:
  25.     def __init__(self, bot):
  26.         self.bot = bot
  27.  
  28.  
  29.     @commands.command(pass_context=True)
  30.     async def lookup(self, ctx):
  31.         ip = ctx.message.content[8:]
  32.         print(ip)
  33.         verify = ip.replace('.', '')
  34.         if verify.isdigit():
  35.             r = requests.get('http://ip-api.com/json/{}'.format(ip), allow_redirects=True)
  36.             country = r.json()['country']
  37.             city = r.json()['city']
  38.             isp = r.json()['isp']
  39.             region = r.json()['region']
  40.             timezone = r.json()['timezone']
  41.             zipcode = r.json()['zip']
  42.             latitude = r.json()['lat']
  43.             longitude = r.json()['lon']
  44.             org = r.json()['org']
  45.             await bot.say('''```
  46. Country: {}
  47. City: {}
  48. ISP: {}
  49. Region: {}
  50. Time Zone: {}
  51. Zip Code: {}
  52. Latitude: {}
  53. Longitude: {}
  54. Organization: {}```'''.format(
  55.                     country, city, isp, region, timezone, zipcode, latitude, longitude, org))
  56.         else:
  57.             await bot.say("you dumb or wat, is that an ip?")
  58.  
  59.  
  60.     @commands.command(pass_context=True)
  61.     async def purge(self, ctx, amount: int, member: discord.Member=None):
  62.         await do_removal(ctx.message, amount, lambda e: member is None or e.author == member)
  63.         '''if member:
  64.            await do_removal(ctx.message, amount, lambda e: e.author == member)
  65.        else:
  66.            await do_removal(ctx.message, amount, lambda e: True)'''
  67.  
  68.  
  69.     @commands.command(pass_context=True)
  70.     async def randint(self, ctx):
  71.         msg = ctx.message.content.split()
  72.         if len(msg) == 3:
  73.             if isint(msg[1]) and isint(msg[2]):
  74.                 await bot.say(random.randint(int(msg[1]), int(msg[2])))
  75.             else:
  76.                 await bot.say('are those ints?!')
  77.         else:
  78.             await bot.say('you need a start and an end integer dumbfook')
  79.  
  80.  
  81.     @commands.command(pass_context=True)
  82.     async def cal(self, ctx):
  83.         msg = ctx.message.content.split()
  84.         args = ''.join(ctx.message.content.split()[1:])
  85.         disallowed = ['**', '/0', '-0', '+0']
  86.         allowed = '0123456789\/*-+.() '
  87.         wl_fail = False
  88.         bl_fail = False
  89.  
  90.         if len(msg) > 1:
  91.             for i in args:
  92.                 if i not in allowed:
  93.                     wl_fail = True
  94.  
  95.             for i in disallowed:
  96.                 if i in args:
  97.                     bl_fail = True
  98.  
  99.             if wl_fail or bl_fail:
  100.                 await bot.say('did you just try to eval bomb me u dickhead')
  101.             else:
  102.                 try:
  103.                     await bot.say(eval(args))
  104.                 except SyntaxError:
  105.                     await bot.say('wtf did you enter??')
  106.         else:
  107.             await bot.say('.calculate takes in only 1 parameter')
  108.  
  109.  
  110.     @commands.command(pass_context=True)
  111.     async def ban(self, ctx):
  112.         msg = ctx.message.content.split()
  113.         author = ctx.message.author
  114.  
  115.         if author.server_permissions.ban_members:
  116.             if len(msg) == 2:
  117.                 if author.top_role > ctx.message.mentions[0].top_role:
  118.                     try:
  119.                         await bot.ban(ctx.message.mentions[0])
  120.                     except discord.errors.Forbidden:
  121.                         await bot.say('u or da bot ain\'t got privilegesss')
  122.                     else:
  123.                         await bot.say('banned this fgt')
  124.             else:
  125.                 await bot.say('which fgt?')
  126.         elif author.id == '205346839082303488':
  127.             if len(msg) == 2:
  128.                 try:
  129.                     await bot.ban(ctx.message.mentions[0])
  130.                 except discord.errors.Forbidden:
  131.                     await bot.say('bot ain\'t got privilegesss, or u didn\'t tag the fgt')
  132.                 else:
  133.                     await bot.say('banned this fgt')
  134.             else:
  135.                 await bot.say('which fgt?')
  136.         else:
  137.             await bot.say('u ain\'t got perms fgt')
  138.  
  139.  
  140.     @commands.command(pass_context=True)
  141.     async def kick(self, ctx):
  142.         msg = ctx.message.content.split()
  143.         author = ctx.message.author
  144.  
  145.         if author.server_permissions.kick_members:
  146.             if len(msg) == 2:
  147.                 if author.top_role > ctx.message.mentions[0].top_role:
  148.                     try:
  149.                         await bot.kick(ctx.message.mentions[0])
  150.                     except discord.errors.Forbidden:
  151.                         await bot.say('u ain\'t got privilegesss, or u didn\'t tag the fgt')
  152.                     else:
  153.                         await bot.say('kicked this fgt')
  154.         elif author.id == '205346839082303488':
  155.             if len(msg) == 2:
  156.                 try:
  157.                     await bot.kick(ctx.message.mentions[0])
  158.                 except discord.errors.Forbidden:
  159.                     await bot.say('bot ain\'t got privilegesss')
  160.                 else:
  161.                     await bot.say('kick this fgt')
  162.             else:
  163.                 await bot.say('which fgt?')
  164.  
  165.  
  166.     @commands.command()
  167.     async def botinfo(self):
  168.         await bot.say('''```
  169.    How many fgts have invited me to their server: {}
  170.    How many shitty channels i am connected to: {}
  171.    How many shitfaces i've encountered: {}```'''.format(len(bot.servers),
  172.                                                          sum([len(s.channels) for s in bot.servers]),
  173.                                                          sum([len(s.members) for s in bot.servers])))
  174.  
  175.  
  176.     @commands.command(pass_context=True)
  177.     async def serverinfo(self, ctx):
  178.         channels = [channel for channel in ctx.message.server.channels if channel.type == discord.ChannelType.text]
  179.         await bot.say('''```
  180.    Dis server is called {},
  181.    {} channels in dis gay server,
  182.    {} members in this server,
  183.    ```'''.format(ctx.message.server.name, len(channels), len(ctx.message.server.members)))
  184.  
  185. def setup(bot):
  186.     bot.add_cog(Public(bot))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement