This repository has been archived by the owner on Feb 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da3eb42
commit 8c58247
Showing
7 changed files
with
61 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,6 @@ | ||
# API Digest 2021 | ||
This repository contains the rules and code of conduct for __API Digest 2021__. | ||
The idea is to create a Telegram Bot for running the code inside Telegram, written in messages. The code has to be written in the message and the bot will return the output. The user can add its username in the bot to receive its details in messages like rating, number of stars etc. | ||
|
||
## Contents | ||
- __[Contents](#contents)__ | ||
- __[Requirements](#requirements)__ | ||
- __[Few pointers](#few-pointers)__ | ||
- __[How to submit?](#how-to-submit)__ | ||
- __[Rules](HackIIITV_rules_and_timeline.pdf)__ | ||
- __[Code of Conduct](CODE_OF_CONDUCT.md)__ | ||
- __[Our Community](#our-community)__ | ||
- __[Contact / Support](#contact--support)__ | ||
We will be using APIs from Codechef, Codeforces or Hackerrank to fetch a random question from any category/difficulty level. | ||
|
||
### Requirements | ||
|
||
- __[GitHub account](https://github.com/login)__ | ||
- Install __[git](https://git-scm.com/)__ for your repsective OS. | ||
- Make sure you are part of IIITV organisation on GitHub, else join __[here](http://getmein.glitch.me/)__ | ||
|
||
### Few pointers | ||
|
||
- You can make at max one commit per hour. | ||
- Don't close your PR. | ||
- No commits after Hackathon ends will be entertained. | ||
- It is required from the teams to keep committing within __three__ hours of the previous commit to keep your hack backed up. | ||
- Make sure your whole project is inside the folder of your team. | ||
- If you have time left, make sure you make a README.md 📄 😉(it will help others to understand your code) | ||
|
||
### How to submit? | ||
|
||
One member from each team have to follow this instructions: | ||
Follow the instructions in order: | ||
|
||
1. Fork this repository. | ||
|
||
2. Clone your fork, using | ||
`git clone https://github.com/<your-username>/api-digest-2021.git` | ||
|
||
3. Change Directory to `api-digest-2021`, using | ||
`cd api-digest-2021` | ||
|
||
4. Set remote to original repository using | ||
`git remote add ups https://github.com/iiitv/api-digest-2021.git` | ||
|
||
5. Create a branch named `team#x`, where __"x"__ is your team number, using | ||
`git checkout -b team#x` | ||
|
||
6. Add a folder with name `team#x - {Chosen_Theme_number}` in root directory. Make sure your whole hack is in folder `team#x - {Chosen_Theme_number}`. | ||
|
||
7. Now add this folder to your staging area, using | ||
`git add "team#x - {Chosen_Theme_number}"` | ||
|
||
8. Now commit the changes using, | ||
`git commit -m "Add team#x"` | ||
|
||
9. Push the changes using, | ||
`git push` | ||
|
||
10. Open a pull request: As soon as the changes will be pushed, GUI of repository's main page will show a yellow banner saying you too open a Pull request, just click on it and you are done. | ||
|
||
For making changes to PR, just keep on repeating Step 6-9. | ||
|
||
### Rules | ||
|
||
- Keep your content as original as possible. | ||
- It is allowed to use available softwares/packages as a module, but they can't be your project. | ||
|
||
### Contact / Support | ||
|
||
- Write to us at: __[[email protected]](mailto:[email protected])__ | ||
- Join the discord server: __[Technical Committee](https://discord.gg/Rw4X9rYZgR)__ | ||
|
||
### Our Community | ||
|
||
- Open source projects created by students at IIITV : [IIITV Open Source Org](https://github.com/iiitv) | ||
- Discord channel where we discuss topics related to DSA and Competitive Programming: [IIITVCC Discord Server Invite](https://discord.gg/pUPbVHF) | ||
- Join the Open Source Org and our Slack Channel to ask your doubts and discussion: [Get Me In](https://getmein.glitch.me/), [Slack](https://join.slack.com/t/iiitvadodara/shared_invite/zt-gx92qvc2-X_NREKMxP6f7DlyZuxzM_g) | ||
|
||
### Happy Hacking! 🖖 | ||
|
||
*** | ||
|
||
<p align='center'>Made With ❤️ By <a href="https://github.com/iiitv">Team API Digest</a></p> | ||
Further, we will try to introduce more features like fetching a random question daily according to user's rating, alert about the upcoming contests and solving language specific ladders. |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
import json | ||
import configparser as cfg | ||
|
||
class CS_toolkit(): | ||
|
||
def __init__(self, config): | ||
self.token = self.read_token_from_config_file(config) | ||
self.base = "https://api.telegram.org/bot{}/".format(self.token) | ||
|
||
def getUpdates(self, offset=None): | ||
url = self.base + "getUpdates?timeout=100" #Timeout = 100 to avoid requesting endpoint again and again | ||
if offset: | ||
url += "&offset={}".format(offset + 1) | ||
|
||
r = requests.get(url) | ||
return json.loads(r.content) | ||
|
||
def sendMessage(self, msg, chat_id): | ||
url = self.base + "sendMessage?chat_id={}&text={}".format(chat_id, msg) | ||
if msg is not None: | ||
requests.get(url) | ||
|
||
def read_token_from_config_file(self, config): | ||
parser = cfg.ConfigParser() | ||
parser.read(config) | ||
return parser.get('creds', 'token') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[creds] | ||
token = 1651920399:AAHrId7JydTx9O4boUEx__MdWt8ZcVbmKNs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from admins import CS_toolkit | ||
|
||
|
||
bot = CS_toolkit("config.cfg") | ||
|
||
|
||
def reply(msg): | ||
if msg == "/start": | ||
return "This is your one-stop bot for all CS related things.\nType /help to see all commands." | ||
if msg is None: | ||
return | ||
if msg is not None: | ||
return "Okay!" | ||
|
||
update_id = None | ||
while True: | ||
updates = bot.getUpdates(offset=update_id) | ||
updates = updates["result"] | ||
if updates: | ||
for item in updates: | ||
update_id = item["update_id"] | ||
try: | ||
msg = item["message"]["text"] | ||
sender = item["message"]["from"]["id"] | ||
except: | ||
msg = None | ||
sender = None | ||
reply_msg = reply(msg) | ||
bot.sendMessage(reply_msg, sender) |