diff --git a/.idea/dictionaries/hubobel.xml b/.idea/dictionaries/hubobel.xml
index 80d46dd..72c30cb 100644
--- a/.idea/dictionaries/hubobel.xml
+++ b/.idea/dictionaries/hubobel.xml
@@ -5,6 +5,7 @@
farbe
fyeg
gibt
+ gibts
nicht
diff --git a/Bahnabfrage.py b/Bahnabfrage.py
index dff105d..7dbdb53 100644
--- a/Bahnabfrage.py
+++ b/Bahnabfrage.py
@@ -3,12 +3,16 @@
import requests
import telebot
import datetime
+import json
+from datetime import datetime as DateTime
hour = datetime.datetime.now().hour
TOKEN='680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4'
ChatID='322673713'
tb = telebot.TeleBot(TOKEN)
-
+ort = '/home/carsten/Scripts/'
+ort = ''
+Zeitstempel = DateTime.now().strftime('%Y_%m_%d_%H_%M_%S')
antwort=''
def mzwi():
@@ -16,6 +20,8 @@ def mzwi():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Mainz - Wiesbaden\n'
+ with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
+ json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "S 8":
if i['destination'] == 'Wiesbaden Hbf':
@@ -44,6 +50,8 @@ def wimz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Wiesbaden - Mainz\n'
+ with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
+ json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "S 8":
if i['destination'] == 'Offenbach(Main)Ost':
@@ -75,6 +83,8 @@ def mzaz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Mainz - Alzey\n'
+ with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
+ json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
if i['train'] == "RE 13":
if i['delayDeparture'] != None:
@@ -105,6 +115,8 @@ def azmz():
resp_zitat = requests.get(url_zitat)
data_zitat = resp_zitat.json()
telegramm = 'Alzey - Mainz\n'
+ with open(ort + str(Zeitstempel) + '_data.txt', 'w') as outfile:
+ json.dump(data_zitat, outfile)
for i in data_zitat['departures']:
# print(i)
if i['train'] == "RE 13":
diff --git a/Bild b/Bild
new file mode 100644
index 0000000..980d297
Binary files /dev/null and b/Bild differ
diff --git a/Chuck2SQL.py b/Chuck2SQL.py
new file mode 100644
index 0000000..d6473a9
--- /dev/null
+++ b/Chuck2SQL.py
@@ -0,0 +1,117 @@
+# -*- coding: UTF8 -*-
+import requests
+import datetime
+import pymysql
+
+
+
+class BotHandler:
+ def __init__(self, token):
+ self.token = token
+ self.api_url = "https://api.telegram.org/bot{}/".format(token)
+
+ #url = "https://api.telegram.org/bot/"
+
+ def get_updates(self, offset=0, timeout=30):
+ method = 'getUpdates'
+ params = {'timeout': timeout, 'offset': offset}
+ resp = requests.get(self.api_url + method, params)
+ result_json = resp.json()['result']
+ return result_json
+
+ def send_message(self, chat_id, text):
+ params = {'chat_id': chat_id, 'text': text, 'parse_mode': 'HTML'}
+ method = 'sendMessage'
+ resp = requests.post(self.api_url + method, params)
+ return resp
+
+ def get_first_update(self):
+ get_result = self.get_updates()
+
+ if len(get_result) > 0:
+ last_update = get_result[0]
+ else:
+ last_update = None
+
+ return last_update
+
+
+token = '1030619458:AAGTrWO2-m38ViL0y2R8XaV0P1gg8kHxj3o' #Token of your bot
+magnito_bot = BotHandler(token) #Your bot's name
+
+
+
+def main():
+ new_offset = 0
+ print('hi, now launching...')
+
+ while True:
+
+ all_updates=magnito_bot.get_updates(new_offset)
+
+ if len(all_updates) > 0:
+ for current_update in all_updates:
+ print(current_update)
+ first_update_id = current_update['update_id']
+
+ if 'text' not in current_update['message']:
+ first_chat_text='New member'
+ else:
+ first_chat_text = current_update['message']['text']
+ first_chat_id = current_update['message']['chat']['id']
+ if 'first_name' in current_update['message']:
+ first_chat_name = current_update['message']['chat']['first_name']
+ elif 'new_chat_member' in current_update['message']:
+ first_chat_name = current_update['message']['new_chat_member']['username']
+ elif 'from' in current_update['message']:
+ first_chat_name = current_update['message']['from']['first_name']
+ else:
+ first_chat_name = "unknown"
+ signal = first_chat_text[0:5]
+
+ if signal == '/0815':
+ magnito_bot.send_message(first_chat_id, 'Ich lausche deinem Befehl ' + first_chat_name)
+ new_offset = first_update_id + 1
+ connection = pymysql.connect(db="hubobel",
+ user="hubobel",
+ passwd="polier2003",
+ host='10.0.1.59', charset='utf8')
+ cursor = connection.cursor()
+ sql = "SELECT * FROM facts ORDER BY nr DESC"
+ resp = cursor.execute(sql)
+ x = int(resp)
+ magnito_bot.send_message(first_chat_id, 'Es gibt derzeit ' + str(x) + ' Facts')
+
+ fact = first_chat_text[6:]
+
+ sql = "INSERT INTO `facts`(`nr`, `fact`) VALUES ('" + str(x+1) + "','" + fact + "')"
+ sql_q = "SELECT * FROM facts WHERE fact like '%" + fact + "%'"
+ resp = cursor.execute(sql_q)
+ if resp == 0:
+ try:
+ resp = cursor.execute(sql)
+ magnito_bot.send_message(first_chat_id, 'Ich habe diesen Fact an SQL übertragen: ' + fact)
+ except:
+ magnito_bot.send_message(first_chat_id, 'Ich hatte ein Problem, den Fact an SQL zu übermitteln!')
+ else:
+ magnito_bot.send_message(first_chat_id, 'Den Fact "' + fact+ ' "gibt es schon in meiner Database!')
+ connection.commit()
+ cursor.close()
+ connection.close()
+ else:
+ if first_chat_text == 'Hi':
+ magnito_bot.send_message(first_chat_id, 'Morning ' + first_chat_name)
+ new_offset = first_update_id + 1
+ elif first_chat_text == 'Wer bin ich':
+ magnito_bot.send_message(first_chat_id, 'Du bist der Größte '+ signal)
+ new_offset = first_update_id + 1
+ else:
+ magnito_bot.send_message(first_chat_id, 'How are you doing '+first_chat_name)
+ new_offset = first_update_id + 1
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except KeyboardInterrupt:
+ exit()
\ No newline at end of file
diff --git a/Euro2SQL.py b/Euro2SQL.py
new file mode 100644
index 0000000..472b6b4
--- /dev/null
+++ b/Euro2SQL.py
@@ -0,0 +1,32 @@
+import bs4 as bs
+import requests
+
+requests.packages.urllib3.disable_warnings()
+sauce = requests.get('https://www.lotto24.de/webshop/product/eurojackpot/result', verify=False)
+soup = bs.BeautifulSoup(sauce.text, 'lxml')
+
+ZahlenEuro = {'Datum': '', 'Z1': '', 'Z2': '', 'Z3': '', 'Z4': '', 'Z5': '', 'Eurozahl1': '', 'Eurozahl2': ''}
+a = 1
+daten = soup.find_all('div', class_="winning-numbers__number")
+for i in daten:
+ print(i.text)
+ if a <= 5:
+ ZahlenEuro['Z' + str(a)] = int(i.text)
+ elif a == 6:
+ ZahlenEuro['Eurozahl1'] = int(i.text)
+ elif a == 7:
+ ZahlenEuro['Eurozahl2'] = int(i.text)
+ a = a + 1
+
+daten = soup.find_all('h2', class_="strong hidden-xs")
+for i in daten:
+ date = i.text
+ date = date.replace(' ', '')
+ date = date.replace('\n', '')
+
+start = (date.find('dem')) + 4
+ende = (date.find('(Alle'))
+ZahlenEuro['Datum'] = date[start:ende]
+print(ZahlenEuro)
+
+
diff --git a/FilosophieTOsql.py b/FilosophieTOsql.py
index 494cab1..708b316 100644
--- a/FilosophieTOsql.py
+++ b/FilosophieTOsql.py
@@ -16,17 +16,18 @@ except:
None
sql = "SELECT * FROM Filosofie ORDER BY Nr DESC"
resp = cursor.execute(sql)
-AnzahlStart=resp
-db=[]
-ergebniss=''
+AnzahlStart = resp
+db = []
+ergebniss = ''
requests.packages.urllib3.disable_warnings()
-sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=1151', verify=False)
+sauce = requests.get('https://www.swr3.de/wraps/fun/filosofie/neu.php?id=1300', verify=False)
soup = bs.BeautifulSoup(sauce.text, 'lxml')
for i in soup.find_all('div'):
- ergebniss=ergebniss+str(i)
-start=(ergebniss.find('href="/wraps/fun/filosofie/neu.php?id=1152&cf=42"> weiter > weiter > ' , '').replace('' , '').replace('' , '').replace('' , '').replace('':
+ if j[:5] != '<':
+ print(i)
+
+
+
+for i in datum:
+ j = str(i)
+ #print(j)
+ if j[:17] == '