Skip to content

Instantly share code, notes, and snippets.

View kavehbc's full-sized avatar
🌴
Traveling... Learning... Having fun...

Kaveh Bakhtiyari kavehbc

🌴
Traveling... Learning... Having fun...
View GitHub Profile
@kavehbc
kavehbc / slack_send_message.py
Last active May 27, 2020 21:08
Python - Send a message to a Slack channel
import json
import requests
def sendSlackMessage(message):
webhook_url = 'here is your webhook_url'
slack_data = {"text": "{}".format(message), "username": "your app name"}
response = requests.post(webhook_url, data=json.dumps(slack_data),
headers={'Content-Type': 'application/json'})
if response.status_code != 200:
raise ValueError('Request to slack returned an error %s, the response is:\n%s'
@kavehbc
kavehbc / telegram_send_message.py
Created May 27, 2020 20:58
Python - Send a message via Telegram
import time
import requests
import urllib.parse
def sendTelegramMessage(message):
bot_token = 'API Token here'
bot_chatID = 'Chat ID here'
message = urllib.parse.query(message)
@kavehbc
kavehbc / python_send_sms_mobilevoip.py
Last active March 28, 2023 02:27
Python - Send SMS via MobileVoIP
import urllib
import urllib.parse
import xmltodict
import requests
def send_sms(to_phone, message):
voip_server = "voipmove.com" # or any other Dellmont servers (find them on MobileVoip.com)
my_username = "my_username"
my_password = "my_password"
from_phone = "from_phone_number" # if a caller ID is already set
@kavehbc
kavehbc / sending_email_yagmail.py
Created May 27, 2020 20:50
Python - Sending email via yagmail
import yagmail
def sendGMail(email):
user = 'your_username@gmail.com'
app_password = 'your_app_password'
to = email
subject = 'test subject 1'
content = ['mail body content']
with yagmail.SMTP(user, app_password) as yag:
yag.send(to, subject, content)
@kavehbc
kavehbc / python_email.py
Created May 27, 2020 20:47
Python - Sending email
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def sendEmail(name, email, filename='message.txt'):
# open a template file
with open(filename, 'r', encoding='utf-8') as template_file:
template_file_content = template_file.read()
@kavehbc
kavehbc / AIWorldCup2018.csv
Last active July 15, 2018 22:35
AI in World Cup 2018
Country Predicted Actual Difference
France 4 1 3
Croatia 9 2 7
Belgium 5 3 2
England 7 4 3
Russia 25 5 20
Brazil 3 6 -3
Uruguay 13 7 6
Sweden 14 8 6
Spain 1 9 -8