Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
invite link edited

Update README.md
tera code to nahi h ye

github link added

1


token hata diya
  • Loading branch information
xeon-zolt committed Nov 12, 2018
1 parent 3d8774d commit 8998d71
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Manas kashyap

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python3 ilugd.py
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# ilugd-bot
Bot for India Linux User Group Delhi

## Author
* Manas Kashyap (about.me/manaskashyap)

## Contributor
* xeon-zolt
8 changes: 8 additions & 0 deletions bot.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[BOT]
invite_link=https://t.me/joinchat/AmwdvEAc48xN_P0xRaR_7Q
website=http://www.linuxdelhi.org/
mailinglist=http://frodo.hserus.net/mailman/listinfo/ilugd
facebook=https://www.facebook.com/ILUGD/
twitter=https://twitter.com/ilugdelhi
meetuplink=https://www.meetup.com/ILUGDelhi/
github=https://github.com/ILUGD
135 changes: 135 additions & 0 deletions ilugd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import configparser
import logging
from telegram import ChatAction,ParseMode
from telegram.ext.dispatcher import run_async
from random import choice
import os

BOTNAME = 'ILUGDbot'

@run_async
def send_async(bot, *args, **kwargs):
bot.sendMessage(*args, **kwargs)

logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.DEBUG)

config = configparser.ConfigParser()
config.read('bot.ini')


updater = Updater(os.environ['token']) # we should use env variable !!
dispatcher = updater.dispatcher


def start(bot, update):
bot.sendChatAction(chat_id=update.message.chat_id, action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text= '''
Hey!! I'm currently Working with Ilug-Delhi To hire me contact my admin
Use /help to get help''')


def website(bot, update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['website'])

def facebok(bot, update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['facebook'])

def invitelink(bot, update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['invite_link'])

def mailinglist(bot,update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['mailinglist'])

def twitter(bot,update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['twitter'])

def meetuplink(bot,update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['meetuplink'])

def github(bot,update):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text=config['BOT']['github'])

def help(bot, update):
bot.sendChatAction(chat_id=update.message.chat_id, action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id, text='''Use one of the following commands
/invitelink - to get Ilug-D Telegram group invite link
/facebook - to get a link to Ilug-D Facebook page
/website - to get Ilug-D website link
/mailinglist - link for our mailing list
/twitter - twitter link for ILUGD
/meetuplink - to get meetup link for ILUGD
/github - link to ilugd github repos
''')


# Welcome a user to the chat
def welcome(bot, update):
message = update.message
chat_id = message.chat.id
phrases = ['Hello {}! Welcome to {} .Please introduce yourself.'.format(message.new_chat_member.first_name,message.chat.title),
'Hi {}! Welcome to {} .let\'s start with introduction.'.format(message.new_chat_member.first_name,message.chat.title)
#'Hello {}! Welcome to {} .Please introduce yourself.'.format(message.new_chat_member.first_name,message.chat.title),
#'Hello {}! Welcome to {} .Please introduce yourself.'.format(message.new_chat_member.first_name,message.chat.title),
#'Hello {}! Welcome to {} .Please introduce yourself.'.format(message.new_chat_member.first_name,message.chat.title)
]
text = choice(phrases)
send_async(bot, chat_id=chat_id, text=text, parse_mode=ParseMode.HTML)


def goodbye(bot, update):
message = update.message
chat_id = message.chat.id
text = 'Goodbye, $username!'
text = text.replace('$username',message.left_chat_member.first_name).replace('$title', message.chat.title)
send_async(bot, chat_id=chat_id, text=text, parse_mode=ParseMode.HTML)

def intro(bot, update):
message = update.message
chat_id = message.chat.id
text = 'Hi everyone,I am a python bot working to serve Ilug-D.'
send_async(bot, chat_id=chat_id, text=text, parse_mode=ParseMode.HTML)

def empty_message(bot, update):

if update.message.new_chat_member is not None:
# Bot was added to a group chat
if update.message.new_chat_member.username == BOTNAME:
return intro(bot, update)
# Another user joined the chat
else:
return welcome(bot, update)

# Someone left the chat
elif update.message.left_chat_member is not None:
if update.message.left_chat_member.username != BOTNAME:
return goodbye(bot, update)


dispatcher.add_handler(CommandHandler('website', website))
dispatcher.add_handler(CommandHandler('facebook', facebok))
dispatcher.add_handler(CommandHandler('help', help))
dispatcher.add_handler(MessageHandler([Filters.status_update], empty_message))
dispatcher.add_handler(CommandHandler('invitelink',invitelink))
dispatcher.add_handler(CommandHandler('mailinglist',mailinglist))
dispatcher.add_handler(CommandHandler('twitter',twitter))
dispatcher.add_handler(CommandHandler('meetuplink',meetuplink))
dispatcher.add_handler(CommandHandler('start', start))
dispatcher.add_handler(CommandHandler('github',github))

updater.start_polling()
updater.idle()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python-telegram-bot==5.3.0
requests==2.12.5
configparser==3.5.0

0 comments on commit 8998d71

Please sign in to comment.