Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. from jabberbot import JabberBot, botcmd
  2. import datetime
  3.  
  4. class SystemInfoJabberBot(JabberBot):
  5.  
  6.     @botcmd
  7.     def spiegel( self, mess, args):
  8.     """Gibt einen Downloadlink zur aktuellen Ausgabe des SPIEGELs aus"""
  9.  
  10.         lines = []
  11.  
  12.         if args.endswith("2009"):
  13.             print "2009"
  14.         else:
  15.             print "2010"
  16.  
  17.             file = open("spiegel_2010.txt", 'r')
  18.             while 1:
  19.                 line = file.readline()
  20.                 if line == '':
  21.                     break
  22.                 lines.append(line)
  23.             file.close()
  24.  
  25.         a, b = {
  26.         1: (0, 1),
  27.         2: (0, 2),
  28.         5: (0, 1),
  29.         6: (0, 2)
  30.         }.get(len(args), (0, 0))
  31.  
  32.         try:
  33.             nr = int(args[a:b])
  34.         except ValueError:
  35.             nr = 0
  36.  
  37.         indexError = "Fehler: Ungueltige Eingabe oder Magazin nicht im Bestand."
  38.  
  39.         try:
  40.             return lines[0-nr]
  41.         except IndexError:
  42.             return indexError
  43.  
  44.     @botcmd
  45.     def frundschau( self, mess, args):
  46.     """Gibt einen Downloadlink zur aktuellen Ausgabe der Frankfurter Rundschau aus"""
  47.  
  48.         today = datetime.date.today()
  49.  
  50.         return today
  51.  
  52.  
  53. username = 'botta-heinz2@im.calug.de'
  54. password = ''
  55. bot = SystemInfoJabberBot(username,password)
  56. bot.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement