From da3eb42cda2401a9ec47b6386a75fa41fc4a88a8 Mon Sep 17 00:00:00 2001 From: Anagha Date: Sat, 20 Feb 2021 19:36:21 +0530 Subject: [PATCH 01/13] Added README --- team#17-education/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 team#17-education/README.md diff --git a/team#17-education/README.md b/team#17-education/README.md new file mode 100644 index 0000000..c460f87 --- /dev/null +++ b/team#17-education/README.md @@ -0,0 +1,6 @@ +# 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. + +We will be using APIs from Codechef, Codeforces or Hackerrank to fetch a random question from any category/difficulty level. + +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. \ No newline at end of file From 8c58247e2b43d5745241f5710d70a9b64a9a33cb Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Sat, 20 Feb 2021 23:17:51 +0530 Subject: [PATCH 02/13] skeleton bot ready --- README.md | 83 +----------------- __pycache__/admins.cpython-39.pyc | Bin 0 -> 1349 bytes team#17-education/README.md | 6 -- .../__pycache__/admins.cpython-39.pyc | Bin 0 -> 1366 bytes team#17-education/admins.py | 27 ++++++ team#17-education/config.cfg | 2 + team#17-education/server.py | 29 ++++++ 7 files changed, 61 insertions(+), 86 deletions(-) create mode 100644 __pycache__/admins.cpython-39.pyc delete mode 100644 team#17-education/README.md create mode 100644 team#17-education/__pycache__/admins.cpython-39.pyc create mode 100644 team#17-education/admins.py create mode 100644 team#17-education/config.cfg create mode 100644 team#17-education/server.py diff --git a/README.md b/README.md index 4dcf895..c460f87 100644 --- a/README.md +++ b/README.md @@ -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//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: __[technical.committee@iiitvadodara.ac.in](mailto:technical.committee@iiitvadodara.ac.in)__ -- 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! 🖖 - - *** - -

Made With ❤️ By Team API Digest

+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. \ No newline at end of file diff --git a/__pycache__/admins.cpython-39.pyc b/__pycache__/admins.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..283f7db4ece5fdee71d02aa873713e055d3103b1 GIT binary patch literal 1349 zcmaJ>&u`N(6!wp#&9V-p4K^es;D9EIw07G8q=}75MdCz3ns$jMg{*eFtZCEPt^{3r zVpsl$_Q=2FE2sSnoOmzUj|>o&{A@qJJp23J=R`|OK7saeZ|n1SPRLJOlpFZSK6L#O zj39z0Bq&B2(0t7T{+vs9+Z);KCP< za4#t2sE8_fT;YiY7%PH9&PD6D4nmWrNk29nR!WO=%-n*mpMc58jAV39GZIokXDlP9 z#fl38nOJ-B^u(Bv-f1?YQQR;xkv$a+8ma0vk5h9#ZPp$8SjkAhd3`wyyDA-oopjiZ zdtoUfPBQ5L9I$9=OTPY%c5VZi8`L*BLIXcu*>7#zEPokrDQuj?d zI)bA&MBJ0wY;13CZ~eU%gLtSLqp#Kr!+02*Fsvd%2MnP#I$62pqj4S4zQYWLy3liG zUcm&IfGVz$Da)vOmNCI*G^2vAkvV-0Uc+WQV{e;=0`-;{|vN zGJpUeW6ppS4pfjaRnK!8_?%J@`;}mtS`NhrsddzoZ#yTE31b16*Nyyw*a5{2Y_$Z* z)jcrR*!V#A0C4e@TE=aZMhV_xDg6p;Y0O6GGWFTF<9nW)d+Tmdp8K#7)QXpS1!xUidCb33TJKG9r#)184$_0- GcOKTKC5bnp!?l?&l5={g_1tqvbHi-uV!52i(i;E~;hJ~@+?%hl>kF~oObe&u@ zKVoi+s~YkZ+K`9(2*xF&0P?Z zNSczUUTH+DGmH2$BAMjJMDi~z@+5stI^K7%C%pm6<~a4&1+60JBVv+Dc1$8JL+MHX zn1YX%Y=g#^fxG}~OLFkJ;KIGvu`P=9FtG#HaEp8Nya&@<2T_t4De0V+B&L$iSV<1* z6PE-$vEKB?zO`esySXXGN!O}WjkL(Rg&u9bE9|GE&5q};X(c4Qcc}7ssEaHf6!|b2 z#ls|3&ad>YH7s-{tn=OpqdLraMx{g7sx7|~eF1{`@oI0k|Hde7`iF_x7yYNo9NJ>s zho?7WGE&BF+}pah{nyzlk=@$f*-&ya5H>0DzK~gxo9_6d3*tD*6C1~E#O#3}bdgS1 z&KT;RSoF?ug{D5timUsu0d63#YvhQPRNpL_WHVY)$=Ar7?ts>^886wK9&zi<{E{EE z=2eD!)76o(Z^lwsWggokQ^mwS+}_%nhU>*}Xq0{U>F7I!7dma-f<@!AF3{@z1Rxv7 z;dAF5m?C$6S_o;PHt=RuZabbvSguw3aeSgvM|H(!EwE}`c=rARoK02AG^8F~W+9zk zX>f67Ilw|W8Ry8j1KOGlAOOgiGa!Wn6=Xv7?TQ9IrxeP+E}`p2{({sV!=2(H5X9eDt$nXWe?|4)B)Xs^@8BF{yp;@E|8oE37C;(jrX z-%mtZ-)PLdzKmiO1-{vcqv90nLgPOI3(#Q10Smk^2>eRh@$2+lf{SReZr$I2)<9L+ V{L7^a9@H^C!XmFg29TV9{Q`^?KSTfk literal 0 HcmV?d00001 diff --git a/team#17-education/admins.py b/team#17-education/admins.py new file mode 100644 index 0000000..c4413a8 --- /dev/null +++ b/team#17-education/admins.py @@ -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') \ No newline at end of file diff --git a/team#17-education/config.cfg b/team#17-education/config.cfg new file mode 100644 index 0000000..78230b3 --- /dev/null +++ b/team#17-education/config.cfg @@ -0,0 +1,2 @@ +[creds] +token = 1651920399:AAHrId7JydTx9O4boUEx__MdWt8ZcVbmKNs \ No newline at end of file diff --git a/team#17-education/server.py b/team#17-education/server.py new file mode 100644 index 0000000..f36d310 --- /dev/null +++ b/team#17-education/server.py @@ -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) \ No newline at end of file From 5cb79cfe66dd39ddfc9b64f0889f3824cb18dc0e Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Sun, 21 Feb 2021 11:43:22 +0530 Subject: [PATCH 03/13] add buttons --- .../__pycache__/admins.cpython-39.pyc | Bin 1366 -> 1424 bytes .../__pycache__/register.cpython-39.pyc | Bin 0 -> 1089 bytes team#17-education/admins.py | 7 ++++-- team#17-education/register.py | 21 ++++++++++++++++ team#17-education/server.py | 23 +++++++++++++----- 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 team#17-education/__pycache__/register.cpython-39.pyc create mode 100644 team#17-education/register.py diff --git a/team#17-education/__pycache__/admins.cpython-39.pyc b/team#17-education/__pycache__/admins.cpython-39.pyc index a864e0a457ca38a68aba672acbeed067d5132e0b..f60ded661f69c17cbab1a2256b30eaf6ea24ebf8 100644 GIT binary patch delta 263 zcmcb{HG!Kqk(ZZ?0SJma3=_U>%#Km?% zqJ|-hA%$@PV+~Uc<3c8JhFX>y<`jlf#v+XxmJ}wSIP*eAbC4(_Sk$V7X#sN$%R)v* zh7^Wi22JM4*363DRRU^7sRcQe@wtgb*`)=x)wP-|MQlLRi$Hc2@q!3GAfd@x#15ox zG3OSiN3kboB$mWyrbO`|>z&-rtSBG?R8$Q15~C0!2P5C)EzIi}r6(t|^az4XE#?3c R984T6TpS$ilUPF;nE^LNHbwvd delta 187 zcmbQheT|DZk(ZZ?0SNwk7$!7rnQ4dX&4afVvv8pafcQpO^c5~c;rHOvbc85vR-f*CZKCI>PrPHtfq z7hx%42Wq^|Uy S4kiv3E)EXX$yThPj7$JRvLlHA diff --git a/team#17-education/__pycache__/register.cpython-39.pyc b/team#17-education/__pycache__/register.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e7c8cd1a3f5de15f69a3c0b51a0c18d335edda2d GIT binary patch literal 1089 zcmZWnL2uJA6po!V%}U2Ksc_;@X{Q|4u?Y!jLI|x0gwQIq!6m9>ve-?tCUIsv8Y|

T1V<@&4oX+watIe&A+#xUhKw zQy+lg4kx)2Emjf{*wdUAZsZb-xw%)gqE_KYe$kHFO^oDT0&0iP?c|k1CeIh2$hhf z6zF4?AxwQ648Bh3xx)ZIymLoUXDGRtU_m+x&`+jf5|U`8%3}lZLIYM$i+u9UQ30g* z^?JBFexrrb<5{Ms@%X9GGb5{UTxFX)ONBO@JNI|C|Jxf87aQ9THwCYg*krOCtE-v^ z)tL<#%gW3!hWctO+9C7xYgB{l)1*1UQy3_=53_;y033ve#C)bG9Ih!%Nk%?U;~W#- zJ|~8LanI>j!h=su695S-BfFM0>ap3Cd<#|@ne_bb)R;=|ZfzwuObrrQgw%RQyffCV zRlcBZ2-MAc%h!=iygc7{m5W%5J`gDq)0d^_%Sqo%MSmjmT%KlSx(h^i6?O$Hnnnpd z>mEsCZ)s8TeW7)n3hNzfXsi~mi%N&CY6EK9PNuP88IJ-0u!sHED77#vc%!SQ@|4L6 zY1gX|(OobOp)?@DZ~Dh?&+puDy?l2RwosZfE(Bw?!&o7Coul7n?4*wK#fd`IR1XdI z$dbYD6^ew8_Q1f8ZW9SRHc;ZEhK|u{9Zswt^CBy?LXmA?fU8u+g+iSbK2(30TA~X+W-In literal 0 HcmV?d00001 diff --git a/team#17-education/admins.py b/team#17-education/admins.py index c4413a8..6c0603d 100644 --- a/team#17-education/admins.py +++ b/team#17-education/admins.py @@ -2,6 +2,7 @@ import json import configparser as cfg + class CS_toolkit(): def __init__(self, config): @@ -16,12 +17,14 @@ def getUpdates(self, offset=None): r = requests.get(url) return json.loads(r.content) - def sendMessage(self, msg, chat_id): + def sendMessage(self, msg, chat_id, reply_markup): url = self.base + "sendMessage?chat_id={}&text={}".format(chat_id, msg) + if reply_markup is not None: + url += "&reply_markup={}".format(reply_markup) 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') \ No newline at end of file + return parser.get('creds', 'token') diff --git a/team#17-education/register.py b/team#17-education/register.py new file mode 100644 index 0000000..eb9b145 --- /dev/null +++ b/team#17-education/register.py @@ -0,0 +1,21 @@ +import requests +import json +from admins import CS_toolkit +from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply +import telegram + +bot = CS_toolkit("config.cfg") + +class Register(): + def __init__(self): + self.platforms = ["Codeforces", "Codechef"] + + def show_options(self, chat_id): + keyBoard = { "inline_keyboard": [ + [ + {"text": "CodeForces", "url": "https://codeforces.com"}, + {"text": "CodeChef", "url": "https://codechef.com"} + ], + ] + } + bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) diff --git a/team#17-education/server.py b/team#17-education/server.py index f36d310..55aabfc 100644 --- a/team#17-education/server.py +++ b/team#17-education/server.py @@ -1,16 +1,28 @@ from admins import CS_toolkit +from telegram import InlineKeyboardButton, InlineKeyboardMarkup +from register import Register bot = CS_toolkit("config.cfg") +register_ = Register() -def reply(msg): - if msg == "/start": - return "This is your one-stop bot for all CS related things.\nType /help to see all commands." +def reply(msg, sender): if msg is None: return + if msg == "/start": + return bot.sendMessage("This is your one-stop bot for all CS related things.\nType /help to see all commands.", sender, None) + if msg == "/help": + return bot.sendMessage("""You can use the following commands: + /start : to start the bot. + /help : to get a list of commands. + /register : to register with your username on a given Competitive programming platform. + """, + sender, None) + if msg == "/register": + return register_.show_options(sender) if msg is not None: - return "Okay!" + return bot.sendMessage("Okay!", sender, None) update_id = None while True: @@ -25,5 +37,4 @@ def reply(msg): except: msg = None sender = None - reply_msg = reply(msg) - bot.sendMessage(reply_msg, sender) \ No newline at end of file + reply(msg, sender) \ No newline at end of file From b5c3dd6ecc802007988c0563f3f31c9d057a7262 Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Sun, 21 Feb 2021 17:38:26 +0530 Subject: [PATCH 04/13] added codeforces module --- .vscode/settings.json | 3 ++ .../__pycache__/admins.cpython-39.pyc | Bin 1424 -> 1423 bytes .../__pycache__/codeforces.cpython-39.pyc | Bin 0 -> 2198 bytes .../__pycache__/register.cpython-39.pyc | Bin 1089 -> 1428 bytes team#17-education/admins.py | 2 +- team#17-education/codeforces.py | 45 ++++++++++++++++++ team#17-education/config.cfg | 6 ++- team#17-education/register.py | 16 +++++-- team#17-education/server.py | 14 +++--- 9 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 team#17-education/__pycache__/codeforces.cpython-39.pyc create mode 100644 team#17-education/codeforces.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6a8620e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "activestate.promptRuntimeCreation": false +} \ No newline at end of file diff --git a/team#17-education/__pycache__/admins.cpython-39.pyc b/team#17-education/__pycache__/admins.cpython-39.pyc index f60ded661f69c17cbab1a2256b30eaf6ea24ebf8..070a851c8eaab30aeb74475cf8460dac6098e7fd 100644 GIT binary patch delta 33 ncmbQh-OtUN$ji&c00d30MhRax@)|NRicYp?65SliWX%i!dT$3# delta 33 ncmeC@p1{qU$ji&c00hMyh6&#`@)|NRicPj>65SlkWWx*qemn<) diff --git a/team#17-education/__pycache__/codeforces.cpython-39.pyc b/team#17-education/__pycache__/codeforces.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..43cd564d6cc0345475f553cd4deeaa0e3544d7c0 GIT binary patch literal 2198 zcmb_dOK%)S5bmD0*J~#sR)Q4-3r0vQ5t~>@kt`rl!s9}$C{c14SsL2Yy}RR`nO?ek zm3T8gB^)Dh z7EUXYKxClh>`$%?j2Y>@ot^YdeLI!K4jW}V5P^5dw7|C(dG7^LkWKRE!`piY542GF zV3_FvJNR1Yp^>8l(7DR9zR>3C?q|E#-r$X3#n!d!R|OxZ%w)1WSa3Qzwo#H~WoD9O z1<#6yCUkP~Rb1P1d0NX*4#S(xI>1kWsmKuoc}gofrI*QxW1LgBa;EgeHQuRTxktei zFAaj<7(*1>S=o~}2CU?{&|f||c@Ziftk?jOSukTGC4L-3Oxn7AVXSwgWoi9fGOle1 zmuf_5x}FMZoyLrH$11l})#+-M2*qn)AVHrHXHT}_lSVZ{&(jv2yt@$T(#HQQ+$$p` z4|7pyVYcVw4a52vwL)mj!*JoFdIvtJi@4yWFGR6E(@hSK6WDkGq>Eu}E`+hXGsU`_ z4>XENsjuyKAPhO86`=k(Tok;W>u_}ypnsEa52g<@*d!oxc{p^`Z-$&YJgT5prckL1 z+TNMAcc#4p+AYxbDgt2e01Q4~J@qR8Y)5;OEO2W}-1-uCZizd;Nv8fufTyW~`DyCv zx_}KKki8z{`z4m44V2L1+^CvaPg$NHvUHdLywtJvI5W(Kkg{Hui^;`r09mSYEXS(T zplYvU!$N4y`oelfJT{Y`?>3t|`>YUqo!7^clh!?`v$Fp$qH_3F!5#Lv^B;PR`0ct1 z!4LMfaafb(un|NhaFfUpcArbIUE@M%n?`g4=K73k z(f#FmTvA-ZF}5Ep;u^;{fxy0vJ^NP&J2t-iPM>DjegNS-tZ3bk+$rVJb3iU2(yIXZ zQwRSy(3n>C?YXSXvr;5OaeOG5;&C{;={m-)quvKcc5R-31ff&!!Sap~Lr6@v?&bpe zcL$ocNKHqUq9c19GZ3Ag%yan&p#d0e*Xc_NriSBD*H<5aarGfC>*&Vk<6@*0w$@pL zP#>Xi3xyFJ@fIHO^)AuY1Nmr{Y5g&5)o6@R$BAh4m-BZJUZRuB3%z1-|9&^Zzd;GG zP7>Qnl0x!vj&wVLa$$KRQTU^1z=HQ!A5ndZ)T@?NQ`l$}-V_q`Ul0!AMm{|2_4jV1 wupKu62aFe4sTKZZY-AvLeZ>le-K)tBT6&uc8-39n^ee3JxgWq(+lici0H7fj{r~^~ literal 0 HcmV?d00001 diff --git a/team#17-education/__pycache__/register.cpython-39.pyc b/team#17-education/__pycache__/register.cpython-39.pyc index e7c8cd1a3f5de15f69a3c0b51a0c18d335edda2d..a1e6e035940be1d88d1af13e6c4551fdec5d872e 100644 GIT binary patch literal 1428 zcmZuw&2HQ_5GJWV?t1MYt@GE@0x1gY!A9asiy&x%xM)$dF^Z(Q2n(pRNNMGjM3v+s z@nUmwu6ctToMWG;0Ixme6?$kpqsw z`#B=EaGwsqC2pVaBG7Dhf~s#MnP9o##( z|B3CCXzt$sdQZtkE?lMCsrgv!es}75mQ`)#vTO^B#A*p$Uf(=te-q8I^P2^eK_Za; zT@PX7$O&BmMsMlsU=>Jq2f7auf<$*n?~CWmeB;=8u)>qcE%Kh>L?C+DlsWaG6i#@S7auS@34L&^ogbFUz33pMtcSjCdhADbre9{d z!zbHGXa;y?lFx+8D(MG{{ukWxO`0C(wL&!fwS1d}R&DtJIy5rKqpazvHHi)4U_J-sw*VvgR9P!Z<--#Te2nCx>8$wz zD_A3MZsGacpi&NHK0)$c!Q0$~=q^al6+#)?p*#Puf8*pPUEa7r`f^*3CNWNMD;kw$ zewbyAmWvwqqYQ>d)a!^DVREdd&v7X)GRt7IO#%uni=E<>2R!b5lac2}!2nuk%@|@n z7P6^YYmh9SJAkb;qA|!2gVZp{4RZq(-qnNDU-f@^J%6~a`CFXn{^gLopRW<)G-m$+ DD=%Jx delta 578 zcmZvZPiqu07{=#KvNPH3ZcAb7L8?$eVHCOurL4(P>Nv^%X=gWU-Yl)# ziidg;>|q%%f`@wa;z{uA*T^UE195NKY!g$ydiceuVyJjCxs-5I*wbQ@Qk z2oOX#n0Lg3__Iyg(1qv31P36ZQ!wO$o|5+<_&F^;(yNcABwG`b(Up!d1H9L0WPj+E zGu4ZUWkwzwONTn2;x--bsQz! zb>w($lyy?G-xUczl+QL*s)gpxpGw&$s@PFS`)Xjis*g42VAV+ggmBkuE$qs6 z7md`*m)XdNcj8j?1q`2m>|S4k&MT(Mlsr$dPb^?Y%obbDj& bGX1|A%Qt#T40CxOe3wUbT~LKOaKgzi!o80G diff --git a/team#17-education/admins.py b/team#17-education/admins.py index 6c0603d..ba431da 100644 --- a/team#17-education/admins.py +++ b/team#17-education/admins.py @@ -10,7 +10,7 @@ def __init__(self, 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 + url = self.base + "getUpdates?timeout=10" #Timeout = 100 to avoid requesting endpoint again and again if offset: url += "&offset={}".format(offset + 1) diff --git a/team#17-education/codeforces.py b/team#17-education/codeforces.py new file mode 100644 index 0000000..e646ab4 --- /dev/null +++ b/team#17-education/codeforces.py @@ -0,0 +1,45 @@ +import requests +import json +from admins import CS_toolkit +from telegram import ForceReply + +bot = CS_toolkit("config.cfg") + +class Codeforces(): + def __init__(self): + self.base = "https://codeforces.com/api/" + + def get_user_info(self, handle): + url = self.base + "user.info?handles={}".format(handle) + r = requests.get(url) + return json.loads(r.content) + + def problem_by_tag(self, tag): + url = self.base + "problemset.problems?tags={}".format(tag) + r = requests.get(url) + return json.loads(r.content) + + def chosen_option(self, chat_id, update_id): + callback = bot.getUpdates(offset=update_id) + update_id+=1 + callback = callback["result"][0]["callback_query"]["data"] + if(callback == "profile"): + bot.sendMessage("Enter your handle: ", chat_id, None) + reply = bot.getUpdates(offset=update_id) + update_id+=1 + reply = reply["result"][0]["message"]["text"] + profile = self.get_user_info(reply) + profile_str = "Profile Name: {}\nRating: {}\nRank: {}\nMax Rating: {}\nMax Rank: {}".format(profile["result"][0]["handle"], profile["result"][0]["rating"], profile["result"][0]["rank"], profile["result"][0]["maxRating"], profile["result"][0]["maxRank"]) + bot.sendMessage(profile_str, chat_id, None) + + + def show_options(self, chat_id, update_id): + keyBoard = { "inline_keyboard": [ + [ + {"text": "Profile", "callback_data": "profile"}, + {"text": "Problem", "callback_data": "problem"} + ], + ] + } + bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) + self.chosen_option(chat_id, update_id) \ No newline at end of file diff --git a/team#17-education/config.cfg b/team#17-education/config.cfg index 78230b3..27c1ca9 100644 --- a/team#17-education/config.cfg +++ b/team#17-education/config.cfg @@ -1,2 +1,6 @@ [creds] -token = 1651920399:AAHrId7JydTx9O4boUEx__MdWt8ZcVbmKNs \ No newline at end of file +token = 1651920399:AAHrId7JydTx9O4boUEx__MdWt8ZcVbmKNs + +[codeforces] +key = fbeb5fb261d83d3bb455a1b087fe44b85fac90d3 +secret = 753015ee556d87425f43b5eed951e447a90ae04d \ No newline at end of file diff --git a/team#17-education/register.py b/team#17-education/register.py index eb9b145..f60b47c 100644 --- a/team#17-education/register.py +++ b/team#17-education/register.py @@ -2,20 +2,28 @@ import json from admins import CS_toolkit from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply -import telegram +from codeforces import Codeforces bot = CS_toolkit("config.cfg") +codeforces = Codeforces() class Register(): def __init__(self): self.platforms = ["Codeforces", "Codechef"] - def show_options(self, chat_id): + def chosen_platform(self, chat_id, update_id): + callback = bot.getUpdates(offset=update_id) + callback = callback["result"][0]["callback_query"]["data"] + if(callback == "cf"): + codeforces.show_options(chat_id, update_id+1) + + def show_options(self, chat_id, update_id): keyBoard = { "inline_keyboard": [ [ - {"text": "CodeForces", "url": "https://codeforces.com"}, - {"text": "CodeChef", "url": "https://codechef.com"} + {"text": self.platforms[0], "callback_data": "cf"}, + {"text": self.platforms[1], "callback_data": "chef"} ], ] } bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) + self.chosen_platform(chat_id, update_id) diff --git a/team#17-education/server.py b/team#17-education/server.py index 55aabfc..2958acc 100644 --- a/team#17-education/server.py +++ b/team#17-education/server.py @@ -7,21 +7,21 @@ register_ = Register() -def reply(msg, sender): +def reply(msg, sender, update_id): if msg is None: return - if msg == "/start": + elif msg == "/start": return bot.sendMessage("This is your one-stop bot for all CS related things.\nType /help to see all commands.", sender, None) - if msg == "/help": + elif msg == "/help": return bot.sendMessage("""You can use the following commands: /start : to start the bot. /help : to get a list of commands. /register : to register with your username on a given Competitive programming platform. """, sender, None) - if msg == "/register": - return register_.show_options(sender) - if msg is not None: + elif msg == "/register": + return register_.show_options(sender, update_id) + elif msg is not None: return bot.sendMessage("Okay!", sender, None) update_id = None @@ -37,4 +37,4 @@ def reply(msg, sender): except: msg = None sender = None - reply(msg, sender) \ No newline at end of file + reply(msg, sender, update_id) \ No newline at end of file From b1361142dc0b64a12b33544a06f9644108f8d2aa Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Sun, 21 Feb 2021 18:17:26 +0530 Subject: [PATCH 05/13] mreged register and gfg --- .../__pycache__/admins.cpython-39.pyc | Bin 1423 -> 1423 bytes .../__pycache__/codeforces.cpython-39.pyc | Bin 2198 -> 2118 bytes .../__pycache__/gfg.cpython-39.pyc | Bin 0 -> 1275 bytes .../__pycache__/register.cpython-39.pyc | Bin 1428 -> 1428 bytes team#17-education/gfg.py | 24 ++++++++++++ team#17-education/server.py | 36 +++++++++++++++++- 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 team#17-education/__pycache__/gfg.cpython-39.pyc create mode 100644 team#17-education/gfg.py diff --git a/team#17-education/__pycache__/admins.cpython-39.pyc b/team#17-education/__pycache__/admins.cpython-39.pyc index 070a851c8eaab30aeb74475cf8460dac6098e7fd..f7ce72fc3b531cf4ad3e0f1e8193585f4f40a8f4 100644 GIT binary patch delta 22 ccmeC@?&s!Bl0qlB*;d7D@PHPZ!J diff --git a/team#17-education/__pycache__/codeforces.cpython-39.pyc b/team#17-education/__pycache__/codeforces.cpython-39.pyc index 43cd564d6cc0345475f553cd4deeaa0e3544d7c0..f0c24a8e754144dc753726d15914bf5d65cbdc89 100644 GIT binary patch delta 90 zcmbOxcuasdk(ZZ?0SJBt8zpdVmFins*k(ZZ?0SIRJ7$vlB4Lu(t&wta?eW>L>kbkPJE-7GVocl1P3=Y} zN@x59uf?t%WlH8{G0*ZM^O3I;0p%eqa~Bv#zW#(T%*Z>G1Pp2f8L}Q!)px=2WSL>O zcSU~h102IL6JQJ%_yVQSI5?2gfd3gVSy5+RGcmF}mS(8y)D!D51VqWiDl%}OD zZJPRF8eb;D?F3qwUmawf(H{W$q4r^Qy_~?tKZ1XNkHini%Yv{0i#p4YjrNv;l=x?2 z(QC}c7ub?tf(!C1W|Q~b_~8`}PTj4tn_IfM99%MbBnqWVyRJ<8)!N$H94!{x?RH*V zK36B_N*9Z~k&IScS}IJe@|b?|T+E0IE&s{7pwXhe^@LhFJ+r#WY@@kp=Qjsta6LAk zt}oipo=VI0o04y*&o!^x2RHj?s;a5n#pRV(oGC52UbMsIqaVKA$5`APqo9_@nTe&c z+{DHCqP_QAaBBDzkij!MRgzCtKDBE;&6N;pTgu`HkTZb-#V)Nntj|Ihyi(SU4VUa0 zH-;A6g|7|#jUH>N+ROqS!9d+0TT`2s%tbJX$Nmd-(AzVQ5;st_hfs%Qa~muO6B6O* zAJXgi-~Dkr_7J+fcRK5NoJp8anz~V%R*E&k?Px# diff --git a/team#17-education/gfg.py b/team#17-education/gfg.py new file mode 100644 index 0000000..fa902ca --- /dev/null +++ b/team#17-education/gfg.py @@ -0,0 +1,24 @@ +import requests +import json +from admins import CS_toolkit +from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply +import telegram + +bot = CS_toolkit("config.cfg") + +class GFG(): + def __init__(self): + self.platforms = ["GeeksforGeeks"] + def options(self, chat_id): + keyBoard = { "inline_keyboard": [ + [ + {"text": "Algorithms", "url": "https://www.geeksforgeeks.org/fundamentals-of-algorithms/"}, + {"text": "Data Structures", "url": "https://www.geeksforgeeks.org/data-structures/"}, + ], + [ + {"text": "Interview Prep", "url": "https://www.geeksforgeeks.org/company-interview-corner/"}, + {"text": "GATE Prep", "url": "https://www.geeksforgeeks.org/gate-cs-notes-gq/"} + ] + ] + } + bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) diff --git a/team#17-education/server.py b/team#17-education/server.py index 2958acc..36525d3 100644 --- a/team#17-education/server.py +++ b/team#17-education/server.py @@ -1,24 +1,58 @@ from admins import CS_toolkit from telegram import InlineKeyboardButton, InlineKeyboardMarkup from register import Register +import json +from gfg import GFG +gfg_links = """{ + "Search": "https://www.geeksforgeeks.org/searching-algorithms/", + "Sort": "https://www.geeksforgeeks.org/sorting-algorithms/", + "DP": "https://www.geeksforgeeks.org/dynamic-programming/", + "DnC": "https://www.geeksforgeeks.org/divide-and-conquer/" + }""" bot = CS_toolkit("config.cfg") register_ = Register() +gfg_ = GFG() +def displayLink(key): + links = json.loads(gfg_links) + if key in links: + return bot.sendMessage(links[key], sender, None) + else: + return bot.sendMessage("Ehh.. maybe a wrong spelling or command, check again.", sender, None) def reply(msg, sender, update_id): if msg is None: return elif msg == "/start": - return bot.sendMessage("This is your one-stop bot for all CS related things.\nType /help to see all commands.", sender, None) + return bot.sendMessage("Hey There!\nThis is your one-stop bot for all CS related things.\nType /help to see all commands.", sender, None) elif msg == "/help": return bot.sendMessage("""You can use the following commands: /start : to start the bot. /help : to get a list of commands. + /gfg : to fetch categories of articles from GeeksforGeeks + /search_algos : to fetch the link to learn about searching algorithms + /sort_algos : to fetch the link to learn about sorting algorithms + /dp : to fetch the link to learn about dynamic programming + /dnc : to fetch the link to learn about divide and conquer /register : to register with your username on a given Competitive programming platform. """, sender, None) + elif msg == "/gfg": + return gfg_.options(sender) + elif msg == "/search_algos": + key = "Search" + return displayLink(key) + elif msg == "/sort_algos": + key = "Sort" + return displayLink(key) + elif msg == "/dp": + key = "DP" + return displayLink(key) + elif msg == "/dnc": + key = "DnC" + return displayLink(key) elif msg == "/register": return register_.show_options(sender, update_id) elif msg is not None: From 8571643d083ad8d1fe76bcba65d1d2f41081b7e9 Mon Sep 17 00:00:00 2001 From: Anagha Date: Sun, 21 Feb 2021 19:36:27 +0530 Subject: [PATCH 06/13] problem button functionality added --- team#17-education/README.md | 9 +++++++++ .../__pycache__/admins.cpython-38.pyc | Bin 0 -> 1408 bytes .../__pycache__/codeforces.cpython-38.pyc | Bin 0 -> 2420 bytes .../__pycache__/gfg.cpython-38.pyc | Bin 0 -> 1259 bytes .../__pycache__/register.cpython-38.pyc | Bin 0 -> 1412 bytes team#17-education/admins.py | 2 +- team#17-education/codeforces.py | 16 +++++++++++++--- team#17-education/server.py | 4 ++-- 8 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 team#17-education/README.md create mode 100644 team#17-education/__pycache__/admins.cpython-38.pyc create mode 100644 team#17-education/__pycache__/codeforces.cpython-38.pyc create mode 100644 team#17-education/__pycache__/gfg.cpython-38.pyc create mode 100644 team#17-education/__pycache__/register.cpython-38.pyc diff --git a/team#17-education/README.md b/team#17-education/README.md new file mode 100644 index 0000000..928f7f4 --- /dev/null +++ b/team#17-education/README.md @@ -0,0 +1,9 @@ +# Team#17 - Telegram Bot + +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. + +We will be using APIs from Codechef, Codeforces or Hackerrank to fetch a random question from any category/difficulty level. + +### To start using the chatbot: [CS_toolkit_bot](http://t.me/CS_toolkit_bot) + +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. \ No newline at end of file diff --git a/team#17-education/__pycache__/admins.cpython-38.pyc b/team#17-education/__pycache__/admins.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed9d31f6b6784ba60298df7e0cbf10690a594012 GIT binary patch literal 1408 zcmaKsOK%%D5P(rU?yumhfjpF~zTm;(xM4DEg8N#5>R@qY2LK=f>U;q?(|Ogej`n zHA%RNl~A2)3O2f`2a=A8)CRn}ii6EfAD_OIuB!5j%uQI!EUwY=DGYlLrkbosP1m$0 zk}A4lH92o~ToJIuM$7wW&du$~!9hCDhEC^tX3}C33A_^R;Eau7q3&R2h0nr^QrGPntu_q0m1zH^RFl4xv9{D9sl&= zx%?%YY3s(|dS8X*{_)}Q(b(yOo9|%(EZ`n@$rY=qc~CRORnl~qA6HFUqWOi^u zpRG6oSF9+5e-n(uV#E=PL>xuEAcac`7xo1lB>kqz-zT&SqM-9BlRo;PiRlTpM@TY) HBqRPGS+`5t literal 0 HcmV?d00001 diff --git a/team#17-education/__pycache__/codeforces.cpython-38.pyc b/team#17-education/__pycache__/codeforces.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..43953a54eb5a167db42bc5987a5f1bf4c0ae5323 GIT binary patch literal 2420 zcmb_eOK%%D5MJ(EvgADM#x>H%qUlR5Vl_d507l!mP17O;Vi-wtSs2)^mz2ELK2(xI zYy%+8(A(KN~2&}A02pODb|-k=V3 zpBmJCVun5?4~>rZ66_hf9ip0d9!9b(vq376`>x~(d%%X-$+(%6MKA4dCB1%v(u+EzD@f~$bHbcPBnS`=4Ur=>`NBs*KXXp&gdwKWm*>d3!4m2lpjTD zk;*7SSOP&BWW4sukFEK7qStU89(y*lLmvWD8AssM8L7yWY#0+$nrBvJPRYcQ_L);z zNA46437lOY3C6e5qF3HNj0>7E@#X2{g~uJRqFe}G9!uqO_VWnb5z6W_sq73f#Gf%ux3$jVDjIjab{A# zf*P4Zr7mdO=i2tUb_2AVplw$MB!vx0;n0;cyK>GYTARiK*IwdQm$(Z{+{H~}>P%cj zQ@L|A#V>&J(!hL9_@2gjdA{-=a5@^NS9u!a8ld;2dj>q9_vt#I_vsse#iv&QgE?tv z42}6ty0SO08M$Sz2WS5hTYz#o6QfLW&8#MImL0^&Ac9oqC(5R=jFkt+)=M)sUb_of z&V!S3#DhA+w*%$nOo+J8lr7n@9PjMa!ohBwv+dw?(tH3lUi4>VG0?>Q_&8YjUbFQY zzXY&Cmus!i=5a9y8+m+Oi-(>ji-AUkSv=mTQN;lyU;xD$%(6`RGeV5J|I*Fo0!(&i zWcPFe|6xNHw2=3xa?*mbkfygoO#UB3ME1*WUAWK+RWhx>AP~8cCTe zH#scRgms#AWAKv0SVk#TjgdBjq(2Y3ayVWI{4ET?3IM{OM?!KQpxt+I($)A{A+}); zfD)BMY^EC^CO(15AT8pPbr`ENs!4Wri+RPjpy8}9x11$oOC^dO7WhNwLF1@lvlMy60L`Lj7k@lu>1w}nI@%n_`+t^hX(jrR>77f_RK^b!z zdV96wIt(3?zXKbo_B=)rW~7$Ev)3^hU)#$VTt@-iMJ$m)S+Jn&1@e$VHe^}(7_$%3 zzNMoZ5$2Zs6kIIZFq4jtt~!9N9h*8liNxcD(H`T*}6g!g(AY>C72@htLU z3q%DPGl*&W#Q)R$%k{31@y0?MT$JC1tb)s~fJ%uX)r_LNq$4=;NVOuUz&NW{IQ(WY z>IB2w(h&I#q+TV0rm%lz literal 0 HcmV?d00001 diff --git a/team#17-education/__pycache__/gfg.cpython-38.pyc b/team#17-education/__pycache__/gfg.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..67821c981be3ed154c28ced6e5a577f47400b688 GIT binary patch literal 1259 zcmaJ=OK;pZ5Ed!zuJ+-kD1x4PSRki8Xt(hth!Lc59$pwh3?oiaKv+PfMM_pokuphj zyMlX4uKfo+w8#7P1-I;7|%m<|4hxWUm3+0nC;%t*=4D>Do2-9y1E!Ctb>sU(U%ZHu_}vl-fV1~WtFH* zmbu|+S5|1dyqQdQ=x*4@K1V;a4;SghCUd3p6b zUe2W|7ey;5shKc@>qHg_`Qo{lVH+9ttFd9Lcz5SHF=TpTRGXVtG2P8?4@}{DqQ6{U zbYC3`!_+SoTThP_Yq|%w`{%N5h}b06wO5i$C74=t!{z>)7uy(%+hdf(uq4-skcR1` zyjXPijyWTmO#ulkH&ZFtR2EZn#-@ejT&^oo?g3IJP$1uAwa4}>vf-&TcC4A8ub9@P zWHx%M;V<-PTQ_Sw(FOlX&XBjECBmIh5FeY#f9mgoLxu2 zAP@GI*~rFN81t~ RyT9uDgoJ2XNNMGjM3v+s z@nU;&u6ctVoMT^!*PikUJ+z(CW(~tFff;dTD9-Sk`Ce~t4+*T@+2Jo=g@pWx#?=*o z@fgHTK}jNMP15z3rW9;evnEIbioT!@n<$N%IE|YmO?qEg^Jb6^C{clo&S^SSgL9Jd zABl`*@{Y*loTXcmz9JL;5i*eD3H8IHSHfvs&nq_x{NA&+u3GhzIy=#skxv%R>Grz! zd1mH|&JTakCRZ<2SD*FwXsHVH*yS+SZBdm6c~Rz==jvi$JO;5}f>H$El`=^sdq>hh z1~PiJ7mR@Nz#Q}}7KaF4egf!G~TcuUDvL;ybUUvO+<@TU9-D$8f8 zfGP)FojItov0#K&)x{sgU{n5j`u&4xXLM<@#!kO`@k~6eN@d+N>#BX(Z}$(sKDazbojQCJq5+$J9wP5`2XO^tO?Smk_dlwH)$ zAXI)Q&+7Ul%je?Pg)(P8l$pys%ZrZ~o`gO)(asM`XV^%(BB#I(#7Ty~!vuf@NWs*DRkD&+fTW|RfYge*;38ZFAE@N-fk`WJ5g~?` z_zjNzjjAVsn15nH51-kEOcUlqr`|fhy?LZS5Y1;0OGBKo<-HfR%B&j0Y^mIhb*sj@ z7`vGo7rL(Xo2o4zK!-*Kc_W&hN|V?i4(4-EehV;?&y}@VseE{9fq#))G@UhHU Date: Sun, 21 Feb 2021 20:47:46 +0530 Subject: [PATCH 07/13] image try --- .../__pycache__/admins.cpython-39.pyc | Bin 1423 -> 1424 bytes .../__pycache__/codeforces.cpython-39.pyc | Bin 2118 -> 2436 bytes .../__pycache__/gfg.cpython-39.pyc | Bin 1275 -> 1275 bytes .../__pycache__/image.cpython-39.pyc | Bin 0 -> 954 bytes .../__pycache__/register.cpython-39.pyc | Bin 1428 -> 1428 bytes team#17-education/image.py | 19 ++++++++++++++++++ team#17-education/server.py | 4 ++++ 7 files changed, 23 insertions(+) create mode 100644 team#17-education/__pycache__/image.cpython-39.pyc create mode 100644 team#17-education/image.py diff --git a/team#17-education/__pycache__/admins.cpython-39.pyc b/team#17-education/__pycache__/admins.cpython-39.pyc index f7ce72fc3b531cf4ad3e0f1e8193585f4f40a8f4..661a12105b056f7d452200f507b83f5851efd9fd 100644 GIT binary patch delta 33 ncmeC@p1{qU$ji&c00b=AMhQ1I@)|NRicPj>65SlkWWx*qahnF& delta 33 ncmbQh-OtUN$ji&c00h5+jS{YJeA()T~OO}x4+)_1(tFtSW;4HKQ zVxqd0A=%gv5)wZ~1|$~#085NzVrA!D74GhR`tJR@@80+FN!9I_N(F+;+Q0L(XErn1P(Q1MYNjwOTW_d3iX-Yt*`3R8yZ}MoQlKIK_VN-Lrdzp%QX#k zb=h8rrfSJ|@7I$ji&c00h5+jS@K7C-TWKI!)Bp7E5JLVQFTJVsmFmVNGFcVMt+XW{P6p zSQ5&}$T|5G<5NbS$s3rqYx5NpKVHoq@Rc0>k7Z%!Z6-CVyj|!xC*=#32WRsN>11Sd)42(RC9E>7B%m-z0G5Sq5VBf_V#SV4Kjd1XBLBk lhJ%rVnS&Jw`M~0u9Ft`@)fwd{dva>?LFIvN;bG!n0s!Z{LGJ(n diff --git a/team#17-education/__pycache__/gfg.cpython-39.pyc b/team#17-education/__pycache__/gfg.cpython-39.pyc index dd3d860e971c2197776c11efca7fc70e9842dfd1..c68e92caf91b0d084f38105ea58ba55151cbb6f5 100644 GIT binary patch delta 22 ccmey(`J0nBk(ZZ?0SH*KjS|jofnbN6rUC9qQg7>RwxsOYt%4d$*8_j`~=K2gkAEJRfIj z8jg6GWa(g(q$Bgbynx99^${2h8KlUfm|8a|0vxF6X!o!nDH|Dr_bULy1vvnb-{4Sa zhAFNgeGU{AI=5<8MBEKjs&YB8ZZRa*lXYPbDg6tv1**pRuIP}DOeoqFpdjOD`

Date: Sun, 21 Feb 2021 23:07:11 +0530 Subject: [PATCH 08/13] added ocr module --- .../__pycache__/image.cpython-39.pyc | Bin 954 -> 1059 bytes .../__pycache__/ocr.cpython-39.pyc | Bin 0 -> 713 bytes team#17-education/image.py | 12 ++++++++---- team#17-education/ocr.py | 13 +++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 team#17-education/__pycache__/ocr.cpython-39.pyc create mode 100644 team#17-education/ocr.py diff --git a/team#17-education/__pycache__/image.cpython-39.pyc b/team#17-education/__pycache__/image.cpython-39.pyc index b473dd48a4b55bda7e5161c19e102c36f027d309..b3b04d1d0c7ed3e6db0ed528cfe288bccafabd58 100644 GIT binary patch delta 471 zcmZvY%}T>S6ouzzGRZWyQSpyLt!{%0!EQvvO~Idyg1U-}7&}qZrkRqA8%+?cFHo~` z*W$`o@KJ)e_Zi$c<4$nke$3%8=N{(We5JNut64~%$Cr)s89cHZus>Q`Ibew4NbeJu z017bEhu|6k86wx*LyR!v2{B`+xs<^Pa?CH4aOgm3wNE_3dDIJqRQRZUJi0x#E7B!$ z+H%t8(Z|`QFvm1Ax|Ip!W@a+Ij+j+PIb~C0U7)U&(TSE5fyN-F#?_2WAOnUbxClW& zv-pHX>w=5BeElwWYQ;BfxAbnx;RHUsd_GFE_dm*Jv+GcpU#KSN(BcgE*;!lDhPGZlbq$+`%`ie1g|)pgF~0& zz`4cA+09QP_YM32?k3#?L!KXb@;(V~@TBGr`h~r@Hi@dn7soW+~BdKJS|6C1HgXvAgtR`BT z!c5H!0I}*?7idOPbAy*epf#i<1%@`7tfArs#9rH7_&wnT-jusxFXq$!ogaAp$EBQ3 zrRd_}4q0$N5+xDw+>0Dqtnd+4?|4VNRea&wZbdb*D}lg<8c^s!1FY@JhT>8?dFsd- zZ~aAESxv%}O0WdQTkjaWAzi7@k~k_2mxX?ma24QH1$E}X%St*7V|E{SryvuF`XVZu IsbLEE7chEG7XSbN diff --git a/team#17-education/__pycache__/ocr.cpython-39.pyc b/team#17-education/__pycache__/ocr.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6c1d39f0bf722b44815c50e30ed08c97669593b6 GIT binary patch literal 713 zcmZWn&2Q5%6u09f3(?AlggA0RLh7L{>j9)`Wk^Nhwn+>wQ6ytxH_htAne7Oz+fLm- z!L2*;FZs%ee}NOvtzeaS(R=p$@b7(v^?E4+Qs2j4K4FA@dS#agDDQyHYY-f9EK#;S zafU$;WKffgU?d19E1ZQN5D$5Di+HpOvWVj|)Q^9`TXfRLE}foHtCU<+c9|BcnN{Vm zn3aY1@6x}l&%i2>&y)o`;sGbOI3qmtsE(XYKe}`-q*ULOmb~!K{!$2+7-3r?1kxwWl19F1684OO9sre%c~wM-i^s%ln>PRnC( zF2v>JKJ81ePOfgCphSy{P8e$(DTQ_MOzE0gM~u~O58Ab&0V@}U;-VkA&3VR|O-mF~`n4NBBosWw%O@~O-}1d5)}_50>P#qYSS=`ZDW$dIo%Hv8 zN-sJlw;uf%LN|5qh)3S$ck%$(1RxT;(fhHEKy%@_QH_fkudBvrAK=JWWj8T9IDQ=3 WgSq5roBl2Qs>mcD5}e?Dl8`?E+_e1w literal 0 HcmV?d00001 diff --git a/team#17-education/image.py b/team#17-education/image.py index 8596085..890079b 100644 --- a/team#17-education/image.py +++ b/team#17-education/image.py @@ -1,8 +1,11 @@ import requests import json from admins import CS_toolkit +from ocr import OCR + bot = CS_toolkit("config.cfg") +ocr_ = OCR() class Image(): @@ -13,7 +16,8 @@ def take_image(self, sender, update_id): image_id = image["result"][0]["message"]["photo"][0]["file_id"] url = bot.base + "getFile?file_id={}".format(image_id) r = requests.get(url) - file_path = r["result"]["file_path"] - print(file_path) - url = "api.telegram.org/file/{}/{}".format(bot.token, file_path) - bot.sendMessage(url, sender, None) \ No newline at end of file + content = json.loads(r.content) + image_file_path = content["result"]["file_path"] + url = "api.telegram.org/file/bot{}/{}".format(bot.token, image_file_path) + # print(url) + return bot.sendMessage(ocr_.ocr_space_url(url), sender, None) \ No newline at end of file diff --git a/team#17-education/ocr.py b/team#17-education/ocr.py new file mode 100644 index 0000000..1995e3f --- /dev/null +++ b/team#17-education/ocr.py @@ -0,0 +1,13 @@ +import requests +import json +from admins import CS_toolkit + + +bot = CS_toolkit("config.cfg") + + +class OCR(): + def ocr_space_url(self, url, api_key="helloworld"): + # print(str(url)) + r = requests.get("https://api.ocr.space/parse/imageurl?apikey=helloworld&url={}".format(str(url))) + return r.content.decode() \ No newline at end of file From 8b7600c4f16fb1b753c71dd3d91e294ab949ce9d Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Mon, 22 Feb 2021 01:08:25 +0530 Subject: [PATCH 09/13] added stackoverflow --- .../__pycache__/image.cpython-39.pyc | Bin 1059 -> 1129 bytes .../__pycache__/ocr.cpython-39.pyc | Bin 713 -> 913 bytes .../__pycache__/stackoverflow.cpython-39.pyc | Bin 0 -> 959 bytes team#17-education/image.py | 7 +++++-- team#17-education/ocr.py | 10 ++++++---- team#17-education/stackoverflow.py | 18 ++++++++++++++++++ 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 team#17-education/__pycache__/stackoverflow.cpython-39.pyc create mode 100644 team#17-education/stackoverflow.py diff --git a/team#17-education/__pycache__/image.cpython-39.pyc b/team#17-education/__pycache__/image.cpython-39.pyc index b3b04d1d0c7ed3e6db0ed528cfe288bccafabd58..bd72abea55f1e7452c5b0fc2731f487daed154dc 100644 GIT binary patch delta 327 zcmZ3?@sfi#k(ZZ?0SJyRF-qv3$a{~A4aji@;^G4nzp64-DNL4Plrait$kSkC0KppO z6c$N_6jmT+17c1nn?sVJmL-xQkI8_cgdvMLg=?}6qdGe`P?RHuXL1&!A|vnQ9!5t= zj+Ff5(%jU%l3VO)nK`NPnJKqe3o`Oc@+aS6RNz$0C@Co@w$j(1{Fm_%quAsFOyZ34 zlW#Dk3rm6A$jHaY!^pwN#Hhf?#;7#ehuO7W5hz?Fk4h+jxGX>d}i=fsqvX9lSP;m809A0G96+Roy05-WJ)ln z^NN6MVB}-uVdP+xnLLTvRa5~eP$Y*+$WMO5EX^he5)_`y%OWk$17eDU2o_Y8V2$#V H-C2|XZ~Y~_ diff --git a/team#17-education/__pycache__/ocr.cpython-39.pyc b/team#17-education/__pycache__/ocr.cpython-39.pyc index 6c1d39f0bf722b44815c50e30ed08c97669593b6..73bbcc87fd3c0c879959a1c35f8b4b87f8190c57 100644 GIT binary patch delta 560 zcmZuuF^|(Q81B!8l;4k+6r_*C*aKc?hqzPmYJ2 zaKENAmN6j0=X3*EAlQav;Y-39555o{Y`iSuFeGXC%e`=(g6$55xskG-Rt8x-G(|bR z_#o7%mLIpP>nn!30DFL~&kzi0fkW#Ve+?VhW8M0OwruTBf;QX}`A$@S_YK~iL>Pd02XGH-b^l^;`BauF*YlzjIo`y{DYiTI9)Es- zI@P}m2aZyN4z~6XBKX78j&ie9?*D91@LAPp<<7JCPIl!xfqx^7N}S%k^*<9E9le-I VzNp2So0#q)L=Zs_dR_#9_Zz56jV=HH delta 342 zcmbQpev*|hk(ZZ?0SNME8YP4eB>33Cl& zGvh)atYxlY&SF`>x{v{A5R+e(?c_j4TP97m$$J@Ph1iqx^GZ_lN^Y^Gq$cO5q-wHE zmSYlUS;hZnL`%wo_Q51mLSZ%>sO7y45QL);ST zSn2@S;+&E$2nYC(7!2o6kDZ&^-Cj>j^RC4z>T`N5s!VlLUH1Cjeh)B*N5U#Rtt!S} ziD^Kc-|r80NAIjMb~MTDu^7EpcH;DO1eLaAo+<0L`p^5@|JY86^4a!_EhT5EaJjBV zbzl7#eRq21W6tv`cbp?&i|`4ZKU^8IdlQn@ZVUm6fJ5MV+Fei<OWACdFG z1y^hlT+?&r!mDV(P8y(xi%}~BxIxd3w5vnz40c=1$9qc Date: Mon, 22 Feb 2021 02:14:52 +0530 Subject: [PATCH 10/13] implemented github --- .../__pycache__/admins.cpython-38.pyc | Bin 1408 -> 1408 bytes .../__pycache__/codeforces.cpython-38.pyc | Bin 2420 -> 2420 bytes .../__pycache__/gfg.cpython-38.pyc | Bin 1259 -> 1259 bytes .../__pycache__/github.cpython-38.pyc | Bin 0 -> 2222 bytes .../__pycache__/image.cpython-38.pyc | Bin 0 -> 1113 bytes .../__pycache__/ocr.cpython-38.pyc | Bin 0 -> 897 bytes .../__pycache__/register.cpython-38.pyc | Bin 1412 -> 1531 bytes .../__pycache__/stackoverflow.cpython-38.pyc | Bin 0 -> 943 bytes team#17-education/config.cfg | 5 +- team#17-education/github.py | 54 ++++++++++++++++++ team#17-education/register.py | 10 +++- 11 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 team#17-education/__pycache__/github.cpython-38.pyc create mode 100644 team#17-education/__pycache__/image.cpython-38.pyc create mode 100644 team#17-education/__pycache__/ocr.cpython-38.pyc create mode 100644 team#17-education/__pycache__/stackoverflow.cpython-38.pyc create mode 100644 team#17-education/github.py diff --git a/team#17-education/__pycache__/admins.cpython-38.pyc b/team#17-education/__pycache__/admins.cpython-38.pyc index ed9d31f6b6784ba60298df7e0cbf10690a594012..fe93a900ed35e5c5423927fd7b3105811aeb3bbd 100644 GIT binary patch delta 19 YcmZqRZs6t$<>lpK0D_v`8@b9@0VLW42LJ#7 delta 19 YcmZqRZs6t$<>lpK0D|g_ja+4{03$U6vj6}9 diff --git a/team#17-education/__pycache__/codeforces.cpython-38.pyc b/team#17-education/__pycache__/codeforces.cpython-38.pyc index 43953a54eb5a167db42bc5987a5f1bf4c0ae5323..1bcd3bfc371767f4479200fd2e402ca36d9267d8 100644 GIT binary patch delta 19 Zcmew&^hJm(l$V!_0SFY0RS=Q1jPUV diff --git a/team#17-education/__pycache__/github.cpython-38.pyc b/team#17-education/__pycache__/github.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8ff628b79f0f3715c5dfd56b53a33331eaa92bd GIT binary patch literal 2222 zcmb^yOKTfPcxK;{Amy z%fp4uU6|@S0E{qNl4Q2hgu>n_oytvIif3-=Res`IoR&cnaF=;6X%apn%xA$X!h)Ah z5;6Lebi=p6kL-7;Y2SaEY9Y##LgVhCkU4+Chvj(E&PClT`a5~ApX2N0;lSoDO!Wl- zPEeP`VU#(qNa8Y(3#&Jin)oba5$prjVr^JMwgMV-Oz^1CgV9k=fyH7Vj=b-~ROlK; z8xs=eLaY*_5{E%{C^s$J0BJIWNtRq?X-hR6_z|Gf8L?{FwZUuKm$ z{QB{?={H56D}4y$HDO+7WCBBesPS=2l|;o~EbNoK;wQuK8D4d=MXv;{$kCXB9VrvS*X+$0Y}^#o#iY>sZu07QI*xc-#|ZDV`T~e-B*R zk(du@mC2LQuz-20i=*g}p(HADn2boR_ zW?G{mD8>oWFzc8l7C3$6)zwZsP+4 zI4}-4Z5(a@(vV|_#TjkrlwK#Nj`g}T#W;9pe&ZeoQ!EZhw8;8&_r>X(Q2Ib=f}W67 zrcEUIvk|0_GH#!1c?IwMQe;elg`(EH)^Fw(TOQWm?nst~%J;2Y1r8|+f&}Y{Enub4 zRfKNPHl1wF&AagE|FUm=mI1p9Gvx;$SH=jia4v+x=8Dx*eFAsOI-ZAM>CJ^wKxPl>nI;_qe2txxMV~a2krVlgNB5>!j@Whe7YI5eVsDb`6g~C{(_Rguj zbLtjQw}IM&0&*J<0_(FCC?%hDwg|vg3)d`Mw{T;NO#RaUr8L1p3dp{6;`~hIhLwJK zasD5qU$N3R&t*C9%d+Kt6&rCNdOgMUTWovMl!}&V!G|cCah+KDOd5)!+EEO_wDVA)AoH)4YPW@7X$v#mO6Bhr5zSN-oZy8 zRDAH{d)yfhxhIh3mN;q6ngmcTP#{ZM&@6;XA>-vb3g4J%_)fXW#|w4ld@o8#qJgeT zr0@Fj68fSI6>wmChLV@zKz@qgLjc{-_7-^!53U0+(ZW^6w@u50(Ee?gT$v-O((f0d zyb7e-FcmflLOV2~n=serSexDeyuGyFd{>?qn%#ak!v6yOl%}Sgrj=l$67f!&J{x7_ z>_)agjKqSU+431;sKiq7*)qh^k=VlUE42S1^glORiTud7=iQe42;bN~6lAO_Y9+A; rnn*)a$B$3CxD8}hGf`QOTFQSDWuh-<3V(%pr!d1n9(Vyf;zrItziTTu literal 0 HcmV?d00001 diff --git a/team#17-education/__pycache__/image.cpython-38.pyc b/team#17-education/__pycache__/image.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7ca3b2867d730b097e7b2a0057b6e4ba8946705c GIT binary patch literal 1113 zcmZ8g&2AGh5VrR}+XSi#LCb{z5+a8tw3kX1Kds7N50r|k0#=chZS17m?yk4C_s}$Z zYHx^lNDdr$3V04*IrSAdG2Rr2@M^|0Ow6BJBm9ANN`#7ND+#5!gsR%!<}M${zMISw3ZpQFHig@{d@3q+iABk%~`LoN3b zs-c}0R{qvrC>cwRV+o%5cI(~H@3E{O58A!{pr_MjhXKw8h`0fYA`Kxh2qwk_3QS@` zX-nDLX*8fcjr`B3f#HB`fruZVBpPFaN3eYY*d;nLMg}py;L?QITtlTXY>t4%5?}{$ zK-??aTSBGv9%TL&5W*2tRRTd1_9J$6R+1ecC<$KJ>}s)6l} z-0HMBsP2*a*n(aD$eS3D4_M{gxUTn15d+P}&Tw%zp^>0XK{L`kWd(1>n)rGX8tJfp zUr>38fva*j6-6R><+v#o0@9R6Sg%NFCY9Td6B@=u+4&)pY`8F>@+E|xUB#cAm8w?R zc_a^q4-Tcw#d@a`<#AimgbsL=wizFEbWZ1h$+NO^R<;_-1Y6B%d~dD}^`Z2BP9jN# zvJL>fa{7#?kyIY1Cj}K!C=+s&btG7(?1V)`C>L&o)JSc~j%lVW*5hH&&|2hCkA?+L zS~X<}n)H>U&!b$`it3z-SJjxnt0o;VVS~b)--PxA*QepX1ivAE2jagrU#xd?&NMsG z-Q3*{pT`3L*ah0lq%xORAFZx*C5_ViD{IS?6un5sEbCSU+xe;TWpoUk)xV_>|p~pv4ij7dF+E<$JdPE{Ip{j@BNf9N} z6@C}WR-k88Q^zb&`hg4ma6F^(TQ$C**Yp!oPDIi;6I`zcCUlhRcf%W6Eo!AJ%v9B# Z;Z0D=dprg6R9`Eh>3P5kn3x`RjNiOI9~b}t literal 0 HcmV?d00001 diff --git a/team#17-education/__pycache__/ocr.cpython-38.pyc b/team#17-education/__pycache__/ocr.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..900b2041cd27c3a645efe04e8d8a96009be5dbca GIT binary patch literal 897 zcmY*X&2AGh5VqI5o9!y8KrKi;gDU0FhW3I~(H2w?KZmwz;bKKH+qJXZ)Eh6h1Ei#< z^g+@C2cClW@RbvkQ4&v<@5kLO*hl_H?8-?!gC3=sO^l|>?;JOwtdKybvd zM0CDmia`%#P!US7w-Fgu5sfesgohJMV-ZadZM;N0;_)@&@g$%L$ET>>_zBt2VH>;j z;FMXV_b`(PEwgP{Qw3OKpO6aYY( z*pZ`y6PKO~3F(xUJojOLDS|@`d;o0rKv*=z98UvF#(08nU|kU#PNOmD$J53Q0zDju zJXnLb0*7npDzwRTX&m18S4D@HZ_cf)%}%G2)#awj^`@z_Ty*M88__ANtPn#j_u=wF zjCOBft%G&<%hh_Xl){c`vD>c;+B)`8{6v_cv_@k9NYlCPt@v!)sY|r@FciibM+#wG z+*7*BtRu#17xs-BxJasu8`pqFS}_0@E^@_%TQQAE?U4eKu%T=lYI~y^Z7467{ zM#!EcfQ~i*Gy~KQLv9Q8zahN>kbdpI*y+|<6*{X-_u27l_Pi_rQy2U<`0Ti`{b+lu zYeiN)*m}Gn_%P2blL<6gx*OfrN_uJUOOt%2Y6I+Hg}Eb?Q0uiLM5z8)Z$@9p#y?^wLcq znNT4{N|GuCp{JQ%d%_E-(e=+rhsAb=`xm@_M^0lQ|0UA~r(9;#hLt-|?8BZz1h zUa=T@R1^}3*^!g5V-TKs$7)OdR$A_k2HlZt_T`JcaZ3pW$g3*mGh42nK{Ir$*dNq- zs|e;ByY;$YZ#9I}$Hv4%sdX!osngTrQJNEz;el2w7`BRR>XLz##{wZ}5*>R759x?|ouYY&Q;mKDjKo_^OqoE%fEOWVnD z;EZ!+ef3hxm3%&tI@aonspPIdwWYHGt3_+s*=7Q>{Qr@s{LXMJCIflbepuEuR>%et KKtMUTxc>mtkdAHu delta 550 zcmZut&ubGw6rT5HvOCG9Yh!O2O(Du!iss{(&$9vy=@8jeB4$gw`{oGuM(W`V{e0V0t;bS-) z*S6O*SA`M8C0!h`Snf0BDgTTqe}r+M;DAMP{OiyPIC+D#yhoLW1PT-$W5$k{VkF}4 zj7MxN_Y$SsUEPUbR{YXy4LXVGr!EtoWo%N&Aj2ubUG$;_QH6?K6^}{}$txBvzio<_p7S;f_J?@VSf$qGa?FZ@ zDnTqy^w-^_Wz=2DKT*vx{Vr1Fw_<=8LU@fgo^P+jPP6O`oMW#0XZNpxPrq(T-B~3_ zE}~Bc!QoDXjg~a8tkT;kGB^fUf?z@){SXQTPzO#0=MGong9R* literal 0 HcmV?d00001 diff --git a/team#17-education/config.cfg b/team#17-education/config.cfg index 27c1ca9..3e6c45f 100644 --- a/team#17-education/config.cfg +++ b/team#17-education/config.cfg @@ -3,4 +3,7 @@ token = 1651920399:AAHrId7JydTx9O4boUEx__MdWt8ZcVbmKNs [codeforces] key = fbeb5fb261d83d3bb455a1b087fe44b85fac90d3 -secret = 753015ee556d87425f43b5eed951e447a90ae04d \ No newline at end of file +secret = 753015ee556d87425f43b5eed951e447a90ae04d + +[github] +key = 9c55329fa6a4aabcb6ca775963f261c943e7c56a \ No newline at end of file diff --git a/team#17-education/github.py b/team#17-education/github.py new file mode 100644 index 0000000..728081c --- /dev/null +++ b/team#17-education/github.py @@ -0,0 +1,54 @@ +import requests +import json +from admins import CS_toolkit +from telegram import ForceReply +import random + + +bot = CS_toolkit("config.cfg") + +class Github(): + def __init__(self): + self.base = "https://api.github.com/" + + def show_options(self, chat_id, update_id): + keyBoard = { "inline_keyboard": [ + [ + {"text": "Profile", "callback_data": "users"}, + {"text": "Search by Username", "callback_data": "search"} + ], + ] + } + bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) + self.chosen_option(chat_id, update_id) + + def get_user_info(self, username): + url = self.base + "users/{}".format(username) + r = requests.get(url) + return json.loads(r.content) + + def search_users(self, username): + url = self.base + "search/users/{}".format(username) + r = requests.get(url) + return json.loads(r.content) + + def chosen_option(self, chat_id, update_id): + callback = bot.getUpdates(offset=update_id) + update_id += 1 + callback = callback["result"][0]["callback_query"]["data"] + if(callback == "users"): + bot.sendMessage("Enter your username: ", chat_id, None) + reply = bot.getUpdates(offset = update_id) + update_id += 1 + reply = reply["result"][0]["message"]["text"] + profile = self.get_user_info(reply) + profile_str = "Profile Name: {}\nCompany: {}\nFollowers: {}\nFollowing: {}\nRepos URL: {}".format(profile["name"], profile["company"], profile["followers"], profile["following"], profile["repos_url"]) + bot.sendMessage(profile_str, chat_id, None) + if(callback == "search"): + bot.sendMessage("Enter username: ", chat_id, None) + reply = bot.getUpdates(offset = update_id) + update_id += 1 + reply = reply["result"][0]["message"]["text"] + profile = self.get_user_info(reply) + profile_str = "Profile URL: {}\nRepos URL: {}".format(profile["html_url"], profile["repos_url"]) + bot.sendMessage(profile_str, chat_id, None) \ No newline at end of file diff --git a/team#17-education/register.py b/team#17-education/register.py index f60b47c..01a1a92 100644 --- a/team#17-education/register.py +++ b/team#17-education/register.py @@ -3,19 +3,22 @@ from admins import CS_toolkit from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply from codeforces import Codeforces +from github import Github bot = CS_toolkit("config.cfg") codeforces = Codeforces() - +github = Github() class Register(): def __init__(self): - self.platforms = ["Codeforces", "Codechef"] + self.platforms = ["Codeforces", "Codechef", "Github"] def chosen_platform(self, chat_id, update_id): callback = bot.getUpdates(offset=update_id) callback = callback["result"][0]["callback_query"]["data"] if(callback == "cf"): codeforces.show_options(chat_id, update_id+1) + if(callback == "gh"): + github.show_options(chat_id, update_id+1) def show_options(self, chat_id, update_id): keyBoard = { "inline_keyboard": [ @@ -23,6 +26,9 @@ def show_options(self, chat_id, update_id): {"text": self.platforms[0], "callback_data": "cf"}, {"text": self.platforms[1], "callback_data": "chef"} ], + [ + {"text": self.platforms[2], "callback_data": "gh"} + ] ] } bot.sendMessage("Please select one of the following:", chat_id, reply_markup=json.dumps(keyBoard)) From 0a7029dd8503540947e70094af3a101d62f8832c Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Mon, 22 Feb 2021 04:33:37 +0530 Subject: [PATCH 11/13] pychache --- .../__pycache__/github.cpython-39.pyc | Bin 0 -> 2238 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 team#17-education/__pycache__/github.cpython-39.pyc diff --git a/team#17-education/__pycache__/github.cpython-39.pyc b/team#17-education/__pycache__/github.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..de0e4a02a71031b54dcf677f427fa667a9f0ced1 GIT binary patch literal 2238 zcmb^yO^X{hRGM#ly&p+73EM9Q(gu9UZW9WDrIgTZ6DaKx5^@<9rn4j2p7qSgkz`Uk zv!~?JL!jrTrR$2UC3qfDuMZlFV0{P@tXCsocb+xaXE$`b@8-RJj<;8b1H?U;>I(pz zpe~8SD05zt#AP5CR&Opf@ma_spaa%oZCFFL1{!os@SxCx@o`S!iRC~X-#&n;&^3%U zBn9h$!#SK@A80*N`+IxYsMzgW_T5}md!V^@oGFg0;$`nOks&bu@#tXx=!xP|9SsXL z$d10@YN*BN2-t72qR*ASb?5UtxBo$Fo>ez)-@V1zIL~w;>Z66Q(Zob)TGWM3(>2r) zl_hk#Ik#nZd6r|~mcs)ifN71o2M9U}o%EZ7F2c3%^l3p)T}@6X3mdAPGq-VPltr%~ zxD7e;8rnEB2ZIZ)XdRl(qArV?r$atD7MWxwd?-b)D7o>+XmQsup5{Mkvz}*Vd7S0L zlw~@bUVh9onGfRQNsOMUvx=KQ*}dtFhb0Fu#^6Gp>sZu07QI*xc-#|ZDV`N|e;-`j zk(eK8mC50F)b)*fEVNluykm@!7Z<^kmnQ=nE6(gG{Fd zGp+Fm6yu0SV9eKOjE&wLKvfXaQ3LU8@qpTZ9SaC`oQOt$I)4S>H9Ebrh{5XJ+{OnO za9|v8+Bn<!D{Kh>AW>_qcc#-w#-t*Jfq4a^%1U(_E zOq)pZr(?(?W!yg3@(P~$rO2293q`GYtzR!Jwr^N}yJJ}zD&Mzq9bQOL5F}Vn?7&kB zT}9{?ZPV%Y!n_NY{xADB=NYiKG*f;6a%GGF3+X~AY_3>6)hBSas^fVGR_w{XM4O$)bn$jmoeJ;y+UzRQJtJs(W(d#L$-(pKNf#hmjYH5j$^NNPllM~}%VapEOn_m4E zQclJbF_tmL64PxzHeod{Ou3Gi?k_q;d}vRfpSBM~HOlJAehm11Tk6n3RwyidJcExx zsQAgF?~yVdzMepuTjr!SZxX<{M1d`7L9-Alg^ZV*D12+K;XCD~A1~Eeyn9hf5)E`! zB7fJHm(Uk&sDLN7XDE3YHsq%WJ_OJWZEum+aN{}v6D?h3eA~24I9hbcwFQzY{eB_J ztH62#rotvcXop608|KCWYtx&6w^!)xcjbAZ*&TKx{4dZ?X=>VOS_w8T5$~kw({WbL zPh<nlwVeMZ%0yqz75)nIPGN?DJn#Z|#EqQ40VR1basU7T literal 0 HcmV?d00001 From 3fb86b427f43bc64c3b03ed52d42e500c17039bb Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Mon, 22 Feb 2021 04:55:55 +0530 Subject: [PATCH 12/13] fixed help --- .../__pycache__/admins.cpython-39.pyc | Bin 1424 -> 1424 bytes .../__pycache__/codeforces.cpython-39.pyc | Bin 2436 -> 2436 bytes .../__pycache__/github.cpython-39.pyc | Bin 2238 -> 2238 bytes .../__pycache__/image.cpython-39.pyc | Bin 1129 -> 1129 bytes .../__pycache__/ocr.cpython-39.pyc | Bin 913 -> 913 bytes .../__pycache__/register.cpython-39.pyc | Bin 1428 -> 1547 bytes .../__pycache__/stackoverflow.cpython-39.pyc | Bin 959 -> 959 bytes team#17-education/server.py | 13 +++++++------ 8 files changed, 7 insertions(+), 6 deletions(-) diff --git a/team#17-education/__pycache__/admins.cpython-39.pyc b/team#17-education/__pycache__/admins.cpython-39.pyc index 661a12105b056f7d452200f507b83f5851efd9fd..52133a7d7f3a79d228c0dbb4b0eaf5c743f6b7eb 100644 GIT binary patch delta 19 ZcmbQhJ%O7mk(ZZ?0SLriZRBcW1pp>#1PlNG delta 19 ZcmbQhJ%O7mk(ZZ?0SH*KH*&SH0std|1A71f diff --git a/team#17-education/__pycache__/codeforces.cpython-39.pyc b/team#17-education/__pycache__/codeforces.cpython-39.pyc index e709dd870c7bdf9438905cafe68ae7e49283b39d..9c0139ebbefbaba7a448dd3fecd4329ebdf38574 100644 GIT binary patch delta 19 YcmZn>ZV~26ZV~267~ delta 19 ZcmdldxKEHPk(ZZ?0SG!DZ{*s-0RS+Y1rY!M diff --git a/team#17-education/__pycache__/image.cpython-39.pyc b/team#17-education/__pycache__/image.cpython-39.pyc index bd72abea55f1e7452c5b0fc2731f487daed154dc..032e28b7656f3a7041c38f62f90edf7de16970ce 100644 GIT binary patch delta 22 ccmaFK@sfi#k(ZZ?0SIz-8YL8MQT#`L!H=?ql z5Ib$c*a#Lm8%zHb`z@^1+D=Y=vsWq3G9Pc=`}TeF&3o&<_WZW*I|SGK_l<{#Q-2jk z)Aj2Y1reozGju~2h-AW^K7S+W%_2@2_UyOdueyP zGyVGHbVLMvfQ+<=AjqIw0aG?=h5TkLWTz{4RT+=^B`kug-$4gFeF#msuP@OnCo(4Z z9#wZzYsNCjs3P+BuE7K}mn2>t1e0g>GOeM}MJf7hLSD3h*$>Yn^VK z$Wd#5&`x(_HLPJWF%<$H)Pch>eU3F@TT6EGOh)=>a0%@R>phJiqCI%dQs`4r$slDj zD`N*B96e)=Wp^vD^+toW|jOEgxxxNb&2@bN$nkBgLc=GdT{Najr}*sODVB zM`M|!i8`g%N@pJ!>0-cY$wX$hg~5XVzvel=I*i45Ag`GRD{hSn#XvmpC(PmD?~cd{Y|9XqG3+L1_?yx-?rg!J}*JiJ(`dmA_?kjT{}n%#d0K7 zZC}*`=zFJ)YO@~c;}{Dbt495b=&ZSg8sy9bt-ylWq+gwMUzi(Op#e8{w9EspJu}TF zXRSk>h8$-7f!cl)tCO8)ZUMzuU?AYbkU3`+STombYHkk>;1_GcA(d_dP1fZJ>wy%P z3`jz{nFJErqwr+iGeus4qM6~N*$>DHx%F?h_!q~r^`QC7$5%%%wZ5z}Y(oh{D2~*{ zQdHIQ$>obx{Rz86_+#sl0Hp;e{HG6&YasLehmV@J#B}b>?km8>uB~EwRsn(uM_VoM y`$DUqXDV*Sdcw3bGpip_POq;AZDyz5L-xhOaU{HcI%gk#`d_07Ul&zyJUM diff --git a/team#17-education/server.py b/team#17-education/server.py index 4fac44e..e7eef63 100644 --- a/team#17-education/server.py +++ b/team#17-education/server.py @@ -33,12 +33,13 @@ def reply(msg, sender, update_id): return bot.sendMessage("""You can use the following commands: /start : to start the bot. /help : to get a list of commands. - /gfg : to fetch categories of articles from GeeksforGeeks - /search_algos : to fetch the link to learn about searching algorithms - /sort_algos : to fetch the link to learn about sorting algorithms - /dp : to fetch the link to learn about dynamic programming - /dnc : to fetch the link to learn about divide and conquer - /platform : to get your profile or a problem from a given Competitive programming platform. + /gfg : to fetch categories of articles from GeeksforGeeks. + /search_algos : to fetch the link to learn about searching algorithms. + /sort_algos : to fetch the link to learn about sorting algorithms. + /dp : to fetch the link to learn about dynamic programming. + /dnc : to fetch the link to learn about divide and conquer. + /platform : to access different online platforms through this bot. + /error : to take an image of your error and search it on stackoverflow. """, sender, None) elif msg == "/gfg": From fa8778a6c96b9ee3b9bd76d4a284a0fa5cf9dad6 Mon Sep 17 00:00:00 2001 From: Anagha Mittal <43825882+anaghamittal@users.noreply.github.com> Date: Sat, 27 Feb 2021 02:14:01 +0530 Subject: [PATCH 13/13] Added steps to run --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c460f87..d69ebb0 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,10 @@ The idea is to create a Telegram Bot for running the code inside Telegram, writt We will be using APIs from Codechef, Codeforces or Hackerrank to fetch a random question from any category/difficulty level. -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. \ No newline at end of file +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. + +### Steps to Run +1. Clone the repository using `git clone https://github.com/anaghamittal/api-digest-2021/`. +2. Go to the folder `team#17-education`. +3. Run `server.py` using `python server.py`. +4. Use the Bot :)