daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from irc import Irc
  2. from auth import Auth
  3. from line import Line
  4. import time
  5. import threading
  6. from threading import Thread
  7. import sys
  8.  
  9.  
  10. #set up the list
  11. reminders = []
  12.  
  13. def checkForTime(time, reminderList):
  14.     # reminderList = dict(reminderList)
  15.     # try:
  16.         # irc.send_message(irc.message.channel, reminderList[int(time.time())])
  17.     # except KeyError:
  18.         # pass
  19.     while True:
  20.         irc.send_message(irc.message.channel, "test")
  21.         print("test")
  22.         time.sleep(10)
  23.        
  24. def irc(host, port, bot_nick, channels, password, my_mask):
  25.     if message.type == "PRIVMSG":
  26.         line = Line(message.suffix, time.time(), message.sender, message.channel)
  27.            
  28.         print(line.channel, line.sender, line.content)                 
  29.  
  30.    
  31.         if message.suffix.startswith("!remindme"):
  32.             neededTime = message.get_parameter("!command").split()[0]
  33.             reminder = message.get_parameter("!command")[len(neededTime)+1:]
  34.             neededTime = neededTime.strip()
  35.             if neededTime[-1] == "s":
  36.                 try:
  37.                     neededTime = neededTime[:-1]
  38.                     neededTime = int(neededTime)
  39.                     neededTime = neededTime + int(time.time())
  40.                     reminders.append((neededTime, reminder))
  41.                 except:
  42.                     pass
  43.             elif neededTime[-1] == "m":
  44.                 try:
  45.                     neededTime = neededTime[:-1]
  46.                     neededTime = int(neededTime)
  47.                     neededTime = neededTime * 60
  48.                     neededTime = neededTime + currentTime
  49.                     reminders.append((neededTime, reminder))
  50.                 except:
  51.                     pass
  52.             elif neededTime[-1] == "h":
  53.                 try:
  54.                     neededTime = neededTime[:-1]
  55.                     neededTime = int(neededTime)
  56.                     neededTime = neededTime * 3600
  57.                     neededTime = neededTime + currentTime
  58.                     #irc.send_message(message.channel, str(neededTime) + " " + reminder)
  59.                     reminders.append((neededTime, reminder))
  60.                 except:
  61.                     pass
  62. #connection details
  63. host = "irc.freenode.net"
  64. port = 6697
  65.  
  66. #bot details
  67. bot_nick = "RemindMe"
  68. channels = "##universesandbox"
  69. password = ""
  70. my_mask = "tripsit/bot/DorkBot"
  71.    
  72. auth = None
  73.  
  74. while True:
  75.     irc = Irc()
  76.     irc.connect(host, port, True)
  77.     irc.nick(bot_nick)
  78.     irc.user(bot_nick)
  79.     irc.join_channel(channels)
  80.            
  81.     while True:
  82.         currentTime = int(time.time())
  83.         irc.update_message_queue()
  84.        
  85.         if irc.message_queue == []:
  86.             break
  87.            
  88.         for message in irc.message_queue:
  89.             print(message.raw_message)
  90.  
  91. if __name__ == '__main__':
  92.     Thread(target = irc(host, port, bot_nick, channels, password, my_mask).start())
  93.     t = threading.Timer(1.0, checkForTime(1, 1))
  94.     t.start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top