Aluf

Bot Imports,def,Uptime -Aluf

Jan 25th, 2015
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.55 KB | None | 0 0
  1. # If you have any doubts with bot making ,pm me on Aluf
  2. # impots and defs are only published
  3. # I am done with my old commands and also bot making ,pm me
  4. # I no longer use the account BQ, i lost its password,if somehow anyone uses it ,its not me
  5. # Account BQ was jacked,i believe the jacker did that for fun since I have never seen the account BQ active after that
  6. # Take Care :)+50
  7.  
  8. ########################################################################
  9. ########################################################################
  10. ####                     Posts  © Aluf                              ####
  11. ####               http://Aluf.chatango.com                         ####
  12. ####                                                                ####
  13.   _____  .__          _____                                         ####
  14.   /  _  \ |  |  __ ___/ ____\                                       ####
  15.  /  /_\  \|  | |  |  \   __\                                        ####
  16. /    |    \  |_|  |  /|  |                                          ####
  17. \____|__  /____/____/ |__|     © Aluf-[www.pastebing.tk]            ####
  18.         \/                                                          ####
  19. ####   Message me anytime for any doubts .CC's i post might not     ####
  20. ####   be working  everytime,so message me for fresh cc's  .        ####
  21. ####   Website :   www.pastebing.tk                                 ####
  22. ####   If you need suggestion for the pastebin bots of chatango     ####
  23. ####   message me,lol i have run all the bots here myself,so        ####
  24. ####   i guess ,i know which is the worst and best   .              ####
  25. ####   Do not ask for my bot code on pm ,i quit years back .        ####
  26. ####   If you have doubts regarding other codes on my pastebin      ####
  27. ####   Still message me on Aluf or tyt or 93. [93 FOR COMPLAINS]    ####
  28. ####   I Have been getting a lot of messages lately for cc's        ####
  29. ####   and the worst part is many want to know to hack cc           ####
  30. ####   I cannot help you with that ,you have to find a way yourself ####
  31. ####   but ofc you can always ask for cc's but don't ask me how to  ####
  32.  ____  _     _     _____                                            ####
  33. /  _ \/ \   / \ /\/    /                                            ####
  34. | / \|| |   | | |||  __\                                            ####
  35. | |-||| |_/\| \_/|| |                                               ####
  36. \_/ \|\____/\____/\_/   ©   PMR [ Add me before messaging ]         ####
  37. ########################################################################
  38.  
  39.  
  40.  
  41.  
  42. import ch
  43. import subprocess
  44. import random
  45. import sys
  46. import os
  47. import re
  48. import cgi
  49. import traceback
  50. import threading
  51. import socket
  52. import time
  53. import urllib
  54. import helperCmd
  55. import datetime
  56. import binascii
  57. import youtube
  58. import json
  59. import winsound
  60. import __future__
  61. import math
  62. from xml.etree import cElementTree as ET
  63.  
  64. lockdown = False
  65.  
  66.  
  67. startTime = time.time()
  68.  
  69. filename = "status.txt"
  70. file = open(filename, 'w')
  71. print("[INF]Setting status to online...")
  72. time.sleep(2)
  73. file.write("Online")
  74. file.close()
  75.  
  76. if sys.version_info[0] > 2:
  77.   import urllib.request as urlreq
  78. else:
  79.   import urllib2 as urlreq
  80.  
  81. owners = ['Aluf']
  82. prefix = "!"
  83.  
  84.  
  85. ## DEFINITIONS
  86. dictionary = dict() #dictionary
  87. f=open("definitions.txt", "r") # read-only
  88. print("[INFO]LOADING DEFINITIONS...")
  89. time.sleep(1)
  90. for line in f.readlines():#for line in f
  91.     try:
  92.         if len(line.strip())>0:
  93.             word, definition, name = json.loads(line.strip()) #load line
  94.             dictionary[word] = json.dumps([definition, name])#dump into dectionary[]
  95.     except:
  96.         print("[ERROR]Can't load definition: %s" % line)
  97. f.close()
  98.  
  99. ## NICKNAMES
  100. nicks=dict()#empty list
  101. f=open ("Nicks.txt","r")#r=read w=right
  102. print ("[INFO] Loading Nicks....")#print
  103. time.sleep(1)#sleep for one second
  104. for line in f.readlines():#loop through eachline and read each line
  105.     try:#try code
  106.         if len(line.strip())>0:#strip the whitespace checkgreater than 0
  107.             user , nick = json.loads(line.strip())
  108.             nicks[user] = json.dumps(nick)
  109.     except:
  110.          print("[error] Can't load nick %s" % line)
  111.     f.close()
  112.  
  113. #ROOMS#
  114. rooms = []
  115. f = open("rooms.txt", "r") # read-only
  116. print("[INFO]LOADING ROOMS...")
  117. time.sleep(1)
  118. for name in f.readlines():
  119.   if len(name.strip())>0: rooms.append(name.strip())
  120. f.close()
  121. #END#
  122.  
  123. ##WHITELIST
  124. whitelist = []
  125. f = open("whitelist.txt", "r") # read-only
  126. print("[INFO]LOADING WHITELIST-LVL-1...")
  127. time.sleep(1)
  128. for name in f.readlines():
  129.   if len(name.strip())>0: whitelist.append(name.strip())
  130. f.close()
  131. #END #
  132.  
  133. ##MASTERS
  134. permitted = []
  135. f = open("permitted.txt", "r") # read-only
  136. print("[INFO]LOADING MASTERS-LVL-3...")
  137. time.sleep(1)
  138. for name in f.readlines():
  139.   if len(name.strip())>0: permitted.append(name.strip())
  140. f.close()
  141. # END #
  142.  
  143. ##HALF MASTERS
  144. hpermitted = []
  145. f = open("hpermitted.txt", "r") # read-only
  146. print("[INFO]LOADING HALFMASTERS-LVL-2....")
  147. time.sleep(1)
  148. for name in f.readlines():
  149.   if len(name.strip())>0: hpermitted.append(name.strip())
  150. f.close()
  151. #END #
  152.  
  153. ## OWNER LVL 4
  154. spermitted = []
  155. f = open("spermitted.txt", "r") # read-only
  156. print("[INFO]LOADING OWNER-LVL-4...")
  157. time.sleep(1)
  158. for name in f.readlines():
  159.   if len(name.strip())>0: spermitted.append(name.strip())
  160. f.close()
  161. # END #
  162. # SN Notifs
  163. notif = []
  164. f = open("notif.txt", "r")
  165. print("[INF]Loading Notifs...")
  166. for name in f.readlines():
  167.   if len(name.strip())>0: notif.append(name.strip())
  168. f.close
  169. ## Last Seen History
  170. filename = "roomhist.txt"#the text file you need to have in same place as bot
  171. hist = dict()
  172. f = open(filename, 'r') #open status.txt and make a writing variable called file
  173. print("[INF]LOADING ROOMHIST")#print to console
  174. time.sleep(1)#pause for one second
  175. for line in f.readlines():
  176.   if len(line.strip())>0:
  177.     nama, waktu, ruang, body = json.loads(line.strip())
  178.     hist[nama] = json.dumps([waktu, ruang, body])
  179. f.close()#close the file
  180. ## Send Notes
  181. sasaran = dict()
  182. f = open ("notes.txt", "r") #read-only
  183. print("[INF] Loading Notes")
  184. time.sleep(1)
  185. for line in f.readlines():
  186.   try:
  187.     if len(line.strip())>0:
  188.       to, body, sender = json.loads(line.strip())
  189.       sasaran[to] = json.dumps([body, sender])
  190.   except:
  191.     print("[Error] Notes load fails : %s" % line)
  192. f.close()
  193.  
  194. #Blacklist# lvl -1
  195. blacklist = []
  196. f = open("blacklist.txt", "r") # read-only
  197. print("[INF]Loading level -1...")
  198. time.sleep(1)
  199. for name in f.readlines():
  200.     if len(name.strip())>0: blacklist.append(name.strip())
  201. f.close()
  202. #END #
  203. #########################
  204. #Change user.name into nick or return user.name
  205. #########################    
  206. def sntonick(username):
  207.     user = username.lower()
  208.     if user in nicks:
  209.         nick = json.loads(nicks[user])
  210.         return nick.title()
  211.     else:
  212.         return user.capitalize()
  213.  
  214. class bot(ch.RoomManager):
  215.     def onInit(self):
  216.         self.setNameColor("808080")
  217.         self.setFontColor("FF6600")
  218.         self.setFontFace("8")
  219.         self.setFontSize(11)
  220.         self.enableBg()
  221.         self.enableRecording()
  222.        
  223.     def googleSearch(self, search):
  224.         encoded = urllib.parse.quote(search)
  225.         rawData = urllib.request.urlopen("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+encoded).read().decode("utf-8")
  226.         jsonData = json.loads(rawData)
  227.         searchResults = jsonData["responseData"]["results"]
  228.         for data in searchResults:
  229.             title = data["title"]
  230.             print(title)
  231.             link = data["url"]
  232.             if "youtube" in link:
  233.                 full = "http://www.youtube.com/watch?v="+link[35:]
  234.                 return('I found: %s <br> %s' % (title, full))
  235.             else:
  236.                 full = link
  237.                 return('I found: %s <br> %s' % (title, full))
  238.             break
  239.          
  240.     def tebayoku_new(self):
  241.         try:
  242.             import urllib.request
  243.             with urllib.request.urlopen("http://tebayoku.blogspot.com/") as url:
  244.                 udict = url.read().decode()
  245.                 udict = udict.replace('\r', '').replace('\n', '')
  246.                 judul = re.findall("<h2 class='post-title entry-title'>(.+?)</h2>", udict, re.S)
  247.                 l=[]
  248.                 num = 1
  249.                 for i in judul:
  250.                     x = '<br/>(%s) <u>%s</u>' %(num,i)
  251.                     l.append("<a target='_blank'>"+x+"</a>")
  252.                     num = num+1
  253.                 string = ' '.join(l[0:10])
  254.                 return string
  255.         except Exception as e:
  256.             return str(e)
  257.          
  258.    
  259.     def onConnect(self, room):
  260.         print("Connected to "+room.name)
  261.        
  262.     def onReconnect(self, room):
  263.         print("Reconnect to "+room.name)
  264.  
  265.     def onFloodingWarning(self, room):
  266.         room.reconnect()
  267.  
  268.     def getAccess(self, user):
  269.         if user.name.lower() == "Aluf": return 2
  270.         else: return 0
  271.        
  272.     def getAccess(self, user):
  273.             if user.name in users: return 1 # user-list
  274.             else: return 0
  275.            
  276.     def getUptime():
  277.     # do return startTime if you just want the process start time
  278.         return time.time() - startTime
  279.  
  280.     #### SYSTEM UPTIME
  281.     def uptime():
  282.  
  283.          total_seconds = float(getUptime())
  284.  
  285.          # Helper vars:
  286.          MINUTE  = 60
  287.          HOUR    = MINUTE * 60
  288.          DAY     = HOUR * 24
  289.  
  290.          # Get the days, hours, etc:
  291.          days    = int( total_seconds / DAY )
  292.          hours   = int( ( total_seconds % DAY ) / HOUR )
  293.          minutes = int( ( total_seconds % HOUR ) / MINUTE )
  294.          seconds = int( total_seconds % MINUTE )
  295.  
  296.          # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
  297.          string = ""
  298.          if days > 0:
  299.              string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  300.          if len(string) > 0 or hours > 0:
  301.              string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  302.          if len(string) > 0 or minutes > 0:
  303.              string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  304.          string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  305.  
  306.          return string;
  307.  
  308.     def getAccess(self, user):
  309.         if user.name in spermitted: return 4 # owner-JP
  310.         elif user.name in permitted: return 3 # masters
  311.         elif user.name in hpermitted: return 2 # half-masters
  312.         elif user.name in whitelist: return 1 # White-list
  313.         else: return 0
  314.        
  315.         #################
  316.         #GLOBALS
  317.         #################
  318.         global activated
  319.         global lockdown
  320.        
  321.     def onMessage(self, room, user, message):    
  322.         print(user.name+": "+message.body)
  323.    
  324.         msgdata = message.body.split(" ",1)
  325.         if len(msgdata) > 1:
  326.             cmd, args = msgdata[0], msgdata[1]
  327.         else:
  328.             cmd, args = msgdata[0],""
  329.         cmd=cmd.lower()
  330.  
  331.         if len(cmd) >0:
  332.             if cmd[0]==prefix:
  333.                 used_prefix = True
  334.                 cmd = cmd[1:]
  335.             else:
  336.                 used_prefix = False
  337.         else:
  338.             return
  339.          
  340.      
  341.        
  342.          ##RoomHist
  343.         nama = user.name
  344.         hist[nama] = json.dumps([(time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time()))), room.name, message.body])
  345.         # SN Notif
  346.         if user.name in blacklist: return
  347.         if user.name in notif and user.name in sasaran:
  348.           room.message(user.name+", you got a note left unread. type .rn to read it")
  349.           notif.remove(user.name)
Advertisement
Add Comment
Please, Sign In to add comment