Skip to content

Commit

Permalink
move to AGPL (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jh0ker committed May 8, 2016
1 parent 9b4f4a4 commit 686cf3f
Show file tree
Hide file tree
Showing 11 changed files with 869 additions and 146 deletions.
11 changes: 11 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Credits

`mau_mau_bot` is written and maintained by [Jannes Höke](https://github.com/jh0ker)

## Contributors

The following wonderful people contributed directly or indirectly to this project:

- [imlonghao](https://github.com/imlonghao)

Please add yourself here alphabetically when you submit your first pull request.
777 changes: 661 additions & 116 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Telegram Bot that allows you to play the popular card game UNO via inline querie

To run the bot yourself, you will need:
- Python (tested with 3.4)
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module version 4.0.1
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module version 4.0.3

Get a bot token from [@BotFather](http://telegram.me/BotFather), place it in `credentials.py` and run the bot with `python3 bot.py`

Expand Down
92 changes: 63 additions & 29 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import logging
from datetime import datetime
from random import randint
Expand Down Expand Up @@ -29,32 +48,37 @@
if BOTAN_TOKEN:
botan = Botan(BOTAN_TOKEN)

help_text = "Follow these steps:\n\n" \
"1. Add this bot to a group\n" \
"2. In the group, start a new game with /new or join an already" \
" running game with /join\n" \
"3. After at least two players have joined, start the game with" \
" /start\n" \
"4. Type <code>@mau_mau_bot</code> into your chat box and hit " \
"space, or click the <code>via @mau_mau_bot</code> text next to " \
"messages. You will see your cards (some greyed out), any extra " \
"options like drawing, and a <b>?</b> to see the current game " \
"state. The greyed out cards are those you can not play at the " \
"moment. Tap an option to execute the selected action. \n" \
"Players can join the game at any time. To leave a game, " \
"use /leave. If a player takes more than 90 seconds to play, " \
"you can use /skip to skip that player.\n\n" \
"Other commands (only game creator):\n" \
"/close - Close lobby\n" \
"/open - Open lobby\n\n" \
"<b>Experimental:</b> Play in multiple groups at the same time. " \
"Press the <code>Current game: ...</code> button and select the " \
"group you want to play a card in.\n" \
"If you enjoy this bot, " \
"<a href=\"https://telegram.me/storebot?start=mau_mau_bot\">" \
"rate me</a>, join the " \
"<a href=\"https://telegram.me/unobotupdates\">update channel</a>"\
" and buy an UNO card game.\n"
help_text = ("Follow these steps:\n\n"
"1. Add this bot to a group\n"
"2. In the group, start a new game with /new or join an already"
" running game with /join\n"
"3. After at least two players have joined, start the game with"
" /start\n"
"4. Type <code>@mau_mau_bot</code> into your chat box and hit "
"<b>space</b>, or click the <code>via @mau_mau_bot</code> text "
"next to messages. You will see your cards (some greyed out), "
"any extra options like drawing, and a <b>?</b> to see the "
"current game state. The <b>greyed out cards</b> are those you "
"<b>can not play</b> at the moment. Tap an option to execute "
"the selected action.\n"
"Players can join the game at any time. To leave a game, "
"use /leave. If a player takes more than 90 seconds to play, "
"you can use /skip to skip that player.\n\n"
"Other commands (only game creator):\n"
"/close - Close lobby\n"
"/open - Open lobby\n\n"
"<b>Experimental:</b> Play in multiple groups at the same time. "
"Press the <code>Current game: ...</code> button and select the "
"group you want to play a card in.\n"
"If you enjoy this bot, "
"<a href=\"https://telegram.me/storebot?start=mau_mau_bot\">"
"rate me</a>, join the "
"<a href=\"https://telegram.me/unobotupdates\">update channel</a>"
" and buy an UNO card game.\n")

source_text = ("This bot is Free Software and licensed under the AGPL. "
"The code is available here: \n"
"https://github.com/jh0ker/mau_mau_bot")


@run_async
Expand Down Expand Up @@ -181,15 +205,17 @@ def select_game(bot, update):

bot.answerCallbackQuery(update.callback_query.id,
text="Please switch to the group you selected!",
show_alert=False)
show_alert=False,
timeout=2.5)
bot.editMessageText(chat_id=update.callback_query.message.chat_id,
message_id=update.callback_query.message.message_id,
text="Selected group: %s\n"
"<b>Make sure that you switch to the correct "
"group!</b>"
% gm.userid_current[user_id].game.chat.title,
reply_markup=InlineKeyboardMarkup(back),
parse_mode=ParseMode.HTML)
parse_mode=ParseMode.HTML,
timeout=2.5)


def status_update(bot, update):
Expand Down Expand Up @@ -230,7 +256,8 @@ def start_game(bot, update, args):
game.play_card(game.last_card)
game.started = True
bot.sendSticker(chat_id,
sticker=c.STICKERS[str(game.last_card)])
sticker=c.STICKERS[str(game.last_card)],
timeout=2.5)
send_async(bot, chat_id,
text="First player: " +
display_name(game.current_player.user))
Expand Down Expand Up @@ -344,6 +371,12 @@ def help(bot, update):
parse_mode=ParseMode.HTML, disable_web_page_preview=True)


def source(bot, update):
""" Handler for the /help command """
send_async(bot, update.message.chat_id, text=source_text,
parse_mode=ParseMode.HTML, disable_web_page_preview=True)


def news(bot, update):
""" Handler for the /news command """
send_async(bot, update.message.chat_id,
Expand Down Expand Up @@ -512,6 +545,7 @@ def do_call_bluff(bot, chat_id, game, player):
dp.addHandler(CommandHandler('close', close_game))
dp.addHandler(CommandHandler('skip', skip_player))
dp.addHandler(CommandHandler('help', help))
dp.addHandler(CommandHandler('source', source))
dp.addHandler(CommandHandler('news', news))
dp.addHandler(MessageHandler([Filters.status_update], status_update))
dp.addErrorHandler(error)
Expand Down
19 changes: 19 additions & 0 deletions card.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


from telegram.emoji import Emoji

# Colors
Expand Down
19 changes: 19 additions & 0 deletions deck.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


from random import shuffle
import card as c
from card import Card
Expand Down
19 changes: 19 additions & 0 deletions game.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import logging
from datetime import datetime

Expand Down
19 changes: 19 additions & 0 deletions game_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import logging

from game import Game
Expand Down
19 changes: 19 additions & 0 deletions player.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import logging
from datetime import datetime

Expand Down
19 changes: 19 additions & 0 deletions results.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


from uuid import uuid4

from telegram import InlineQueryResultArticle, InputTextMessageContent, \
Expand Down
19 changes: 19 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#!/usr/bin/env python3
#
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


from telegram import Emoji


Expand Down

0 comments on commit 686cf3f

Please sign in to comment.